| 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: 8566
|
|
|
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.
|
[Donate a pint, save a life!] [How to ask questions] [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
|
 |
 |
|
|
subject: GWT and JPA
|
|
|