-
1. Re: CMP2 ejbSelect method.
lcranford Jun 29, 2002 1:13 PM (in response to xlahaut)I think the proper way to declare one-to-many relationships in EJB-QL is as follows:
SELECT OBJECT(l) FROM Letter AS l, IN (l.template) t WHERE t.logicalName = ?1
You have to use the IN clause when dealing with collections as a cmr field. I'm assuming that template is defined as a collection or set in the Letter Bean -
2. Re: CMP2 ejbSelect method.
xlahaut Jul 1, 2002 4:43 AM (in response to xlahaut)The CMR field template is not a collection, the one to many relation ship is define like this in my ejb-jar.xml :
<ejb-relation>
<ejb-relation-name>Letter-Template</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Letter-has-an-Template</ejb-relationship-role-name>
Many
<relationship-role-source>
<ejb-name>LetterBean</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>template</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Template-has-many-Letters</ejb-relationship-role-name>
One
<relationship-role-source>
<ejb-name>TemplateBean</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
So in this case I don't need to use the IN keyword. My ejbSelect method is used in a ejbHome method in the LocalHome interface of the LetterBean. All of my beans are deployed in the same JVM. Have you got any other suggestions ?
xla -
3. Re: CMP2 ejbSelect method.
dsundstrom Jul 1, 2002 12:03 PM (in response to xlahaut)Are you getting errors? What is the generated SQL? Does it look correct? Try executing the sql by hand in your database.
-
4. Re: CMP2 ejbSelect method.
xlahaut Jul 1, 2002 12:14 PM (in response to xlahaut)No, I do not have any errors, it's simply does not return the result I'm waiting for. I don't known how to see the generated sql request. Could you tell me how to ?
Thanks.
xla. -
5. Re: CMP2 ejbSelect method.
dsundstrom Jul 1, 2002 12:23 PM (in response to xlahaut)The should be in the server.log. If they are not, you will need to increase the log level of the org.jboss.ejb.plugins.cmp category to DEBUG in the log4j.xml file. Directions are contained in the log4j.xml file.
-
6. Re: CMP2 ejbSelect method.
xlahaut Jul 1, 2002 12:47 PM (in response to xlahaut)Here is the generated sql request :
SQL: SELECT t0_l.ID_LETTER, t0_l.APPLICATION_NUMBER, t0_l.GENERATION_DATE, t0_l.SENT_DATE, t0_l.FAX_COVER_PAGE, t0_l.owner, t0_l.storeLocation, t0_l.recipient, t0_l.description, t0_l.status, t0_l.storageType, t0_l.storageReference, t0_l.ID_ENTITY_FK, t0_l.ID_TEMPLATE_FK FROM LETTER t0_l, TEMPLATE t1_l_template WHERE (t1_l_template.LOGICAL_NAME = ?) AND (t0_l.ID_TEMPLATE_FK=t1_l_template.ID_TEMPLATE)
It seems to be normal, I do not see where the problem. I've got the impression that the object Template is not in the object Pool just when I sent the request.