Can you do a findBy from the "end" bean in a unidirectional relationship?
For example:
Give me the "state bean collection" for all states that have a location.
So a Location bean has an Address bean that has a State bean.
In sql it would be "SELECT DISTINCT STATE.STATE_ID WHERE LOCATION.ADDRESS_ID = ADDRESS.ADDRESS_ID AND ADDRESS.STATE_ID = STATE.STATE_ID"
Is this possible in EJB-QL?
Thanks
-
EJB QL question for CMP with relationships (4 messages)
- Posted by: Rex Beiring
- Posted on: September 27 2001 16:57 EDT
Threaded Messages (4)
- EJB QL question for CMP with relationships by Mr Hunj on September 27 2001 22:30 EDT
- EJB QL question for CMP with relationships by Mr Hunj on September 27 2001 22:36 EDT
- EJB QL question for CMP with relationships by Rex Beiring on September 28 2001 10:53 EDT
- EJB QL question for CMP with relationships by Gal Binyamini on September 29 2001 05:34 EDT
- EJB QL question for CMP with relationships by Rex Beiring on September 28 2001 10:53 EDT
-
EJB QL question for CMP with relationships[ Go to top ]
- Posted by: Mr Hunj
- Posted on: September 27 2001 22:30 EDT
- in response to Rex Beiring
you should use "ejbSelect" instead "find" method if you want to make this ejb-ql work.
-
EJB QL question for CMP with relationships[ Go to top ]
- Posted by: Mr Hunj
- Posted on: September 27 2001 22:36 EDT
- in response to Rex Beiring
Sorry,I misunderstood your meaning.
You can use "astract-schema-name" which you defined in your ejb-jar.xml for each cmp bean, to make your query. -
EJB QL question for CMP with relationships[ Go to top ]
- Posted by: Rex Beiring
- Posted on: September 28 2001 10:53 EDT
- in response to Mr Hunj
The problem is that it is on the wrong end of the unidirectional relationship.
The "State Entity" does not know about the address/location.
Is there a way to get a state collection relating back up the chain? -
EJB QL question for CMP with relationships[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: September 29 2001 17:34 EDT
- in response to Rex Beiring
Try this:
SELECT DISTINCT OBJECT(loc.address.state)
FROM Location loc
This finds all the locations, and get's the state associated with the address associated with the location.
Gal