This content has been marked as final.
Show 3 replies
-
1. Re: How can I use a EJB Query with this?
dornus Jan 24, 2006 10:30 AM (in response to dornus)Also, if I did it the EJB way that I showed in my previous post, that would require me to create an
@Transient int count
in MyTableA's java file to store the count.
Also, what if I wanted to sort the results by the count? This would require a lot more work instead of a simple order by clause.
Is there a better way to restructure the Entity classes? Is there a better way to nest EJB queries? -
2. Re: How can I use a EJB Query with this?
dornus Jan 24, 2006 11:48 AM (in response to dornus)Maybe I should create a view in the database and create a POJO from that?
I'm thinking that would be my best bet. -
3. Re: How can I use a EJB Query with this?
chrismalan Feb 25, 2007 6:49 PM (in response to dornus)Hi Dornus,
There are two solutions I can think of. The first side-steps an EJB query.
One of class A's attributes will be a collections of some sort of class B. Simply get an instance of class A by primary key, get an instance of the collection of Bs and do a bees.size().
The second is to do a join. Something like select ab from A as a join a.b as ab where a.PrimaryKey=PK and then again a size() on ab.