« Return to Thread: Uregntly need help for thesis: Batch reading of collection with lazy OneToOne relation

Re: Uregntly need help for thesis: Batch reading of collection with lazy OneToOne relation

by tware :: Rate this Message:

Reply to Author | View in Thread

EclipseLink allows multi-level fetch joins and batch reading.  Have you tried
any of these?

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

(something like @QueryHint(name = QueryHints.LEFT_FETCH, value =
"p.roles.bankAccount")

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Batch
  (something like @QueryHint(name=QueryHints.BATCH, value="p.roles.bankAccount");

Mario Schwarz wrote:

> Hi everybody.
>
> I have to do a run time comparison on Eclipselink and Hibernate for my Bachelor Thesis. I really have an urgent problem, I don't get BatchReading to work correctly.
>
> I implemented use-case based test cases that call specific methods of a  SessionBean called "PartnerService". PartnerService acts as a Facade and manages the transactions (@TransactionAttributeType.REQUIRED). It calls methods on a DAO called "PartnerDAO". PartnerDAO requires an open transaction (@TransactionAttributeType.MANDATORY)
>
> I have the following NamedQuery which retrieves me all partners with their addresses and their roles:
>
> @NamedQuery(name = "getAllPartnersWithAdressesAndRoles", query = "SELECT p FROM Partner as p ", hints = {
> @QueryHint(name = QueryHints.LEFT_FETCH, value = "p.roles"),
> @QueryHint(name = QueryHints.LEFT_FETCH, value = "p.addresses"),
> @QueryHint(name = QueryHints.JDBC_FETCH_SIZE, value = "1000") })
>
> Now I also want to retrieve the bank account of the specific role "employee"  which is a unidirectional onetoone-relation. In the PartnerDAO-method I do the following:
>
> public List<Partner> findAllPartners() {
>   Query q = em.createNamedQuery("getAllPartnersWithAdressesAndRoles");
>   // results in just 1 SELECTs
>   List<Partner> l = q.getResultList();
>   for (Partner partner : l) {
>     for (Role role : partner.getRoles()) {
>       // results in l.size() SELECTs
>       BankAccount ba = ((Employee) role).getBankAccount();
>     }
>   }
> }
>
> My goal is to iterate over all roles and retrieve all BankAccounts in a single SELECT. I guess the problem is, that BankAccount has no ForeignKey of its Employee. With Hibernate it works though. Oh, by the way, I am not able to change the mapping to bidirectional anymore!
>
> Any help is more than appeciated!
> Thanks
> Mario  
>
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

 « Return to Thread: Uregntly need help for thesis: Batch reading of collection with lazy OneToOne relation