This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GWT and JPA

 
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
Saloon Keeper
Posts: 11090
13
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