Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] JPA:how to avoid join table for ManyToOne

hello all,

   for example

  @Entity
  class A {
     @Id
     long a_id;

    String a_name;

     @ManyToOne
     @JoinTable(name="b_id")
     B b;
 }


@Entity
class B {
   @Id
   int b_id ;

   String b_name;

}

jpa query:
    SELECT o from A o where o.b.id = 1


I hope the generated sql like:
   select a_id,a_name from A where b = 1;

but the eclipselink generated the following sql

  select t0.a_id,t0.a_name from A t0, B t1 where t0.b = t1.b_id AND t1.b_id = 1


This is, my table A is very very large table , maybe more than 40m rows; table B is small, 1,000 - 10,000rows. I can't afford  the performance lost due to any join operation for table A .
 Any suggestion except native sql?  I hope all place like this should not use join table, for the sake of performance.

thanks


Back to the top