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
The CMR field template is not a collection, the one to many relation ship is define like this in my ejb-jar.xml :
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 ?
Are you getting errors? What is the generated SQL? Does it look correct? Try executing the sql by hand in your database.
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 ?
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.
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.