Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GWT and JPA  RSS feed

 
Debapriya Dutta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ..."
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!