aspose file tools*
The moose likes Object Relational Mapping and the fly likes GWT and JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "GWT and JPA" Watch "GWT and JPA" New topic
Author

GWT and JPA

Debapriya Dutta
Greenhorn

Joined: Oct 24, 2012
Posts: 1
We have two entities:
Entity A and Entity B. Entity B has a foreign key from Entity A. In the client we have a celltable populated with data from Entity A and there is a column that reference how many Entity B elements exist for each Entity A row.

Is there an easy way to fetch the count of entity B records for each entity A and then have it be a sortable column?

Thanks in advance. I am sorry if the question is a little vague - it's kind of sensitive work information that I am not sure I can explain in too great a detail.

Priya
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

From the UI perspective, it does not matter how your data is generated, so I will move this question to a more appropriate forum for you.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
There are two ways,

1 - just access A's collection of B's and get the size. To optimize how the bs are loaded you can use join fetching, or batch fetching.

2 - Use a count in your query, "Select a, count(b) from A a join a.bs b where ..."


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GWT and JPA