Skip to main content

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

Thank you two answer my email.

  Using read-only basic mapping is one choice,but I need many changes. I check generated sql because I do the last step: optimize query(performance).  I hope these are any QueryHints could do this, but I din't find, i guess Hibernate would not use join table if only associated entity's id occurs in the query.
  eclipselink still have many things need me learn, because of the difference between hibernate and eclipselink.




On Wed, Apr 22, 2009 at 1:48 AM, Zarar Siddiqi <zarars@xxxxxxxxx> wrote:
Instead of the @JoinTable use @JoinColumn(name="b").



On Tue, Apr 21, 2009 at 1:44 PM,  <cn.thesky@xxxxxxxxx> wrote:
> 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
>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top