Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] criteriaquery : fetch not working

 Hi,

Thanks a lot, it's much better now :-) You put some light in the dark zones in my mind concerning Eclipselink ;-)

I changed some defaults in the mapping (from default to lazy in most cases).

I also added @BatchFetch annotations on some @OneToMany mappings. Some things just never need to be read one by one. As I can't go into the whole team's code (everyone doing things without too much concertation), I think that's the best thing to do.

A few more questions:

- @BatchFetch introduces a nice default, but in some cases, such as the one I was describing, I'd like to override that like this:
        root.fetch(EtdOffEtd_.etdOffEtdSesCollection, JoinType.LEFT);

Now, if I do both this and leave the @BatchFecth annotation, it just seems to do both. Is there a way to disable the batch fetch when needed?

- what's the difference between root.fetch() and root.join() in this case?
- I don't really understand if the link you provided could help me further? Could I still improve the code with this?

Best regards,

Yanncik


Le 4/08/2011 19:20, Tom Ware a écrit :
The default is LAZY for xToMany and EAGER for xToOne. To allow LAZY to work on xToOne, you will have to not only ensure the mapping is marked as LAZY, but also ensure EclipseLink can weave the classes. The classes will be weaved by default on a Java EE 5 compliant container. You will have to use set the eclispelink jar file as with the -javaagent flag in Java SE if you are running standalone. Other cases require other configuration - which are you using?

Looking more closely at your query, you are likely getting more joins than you need. For instance, you are both fetch joining and joining EtdOffEtd_.etdInscCoursCollection. Each of those will result in a join.

You may want to consider using our fetch join query hint that allows you to do multiple level fetch joins.

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Join_Fetch






Back to the top