-
1. Re: Error with EJB relationship
juhalindfors Apr 21, 2003 4:59 AM (in response to joanwaters)can't see the source attachment...
curious about your accessor method naming, since you're using all uppercase DEPT_ID as your CMR field name... this field is case sensitive, so for instance setDepartmentID maps to <field-name>departmentID</field-name> (notice the change in case) -
2. Re: Error with EJB relationship
joanwaters Apr 22, 2003 12:43 AM (in response to joanwaters)Hi Juha,
I was't able to attach the files then. -
3. Re: Error with EJB relationship
juhalindfors Apr 23, 2003 5:54 AM (in response to joanwaters)try switching the key field mapping to the EMP side of the relationship in jbosscmp-jdbc.xml
-
4. Re: Error with EJB relationship
joanwaters May 3, 2003 9:38 PM (in response to joanwaters)I have changed as you said but still the problem exists, please see the attachments.
-
5. Re: Error with EJB relationship
jonlee May 6, 2003 1:20 AM (in response to joanwaters)The XML looks fine. As a test to see whether the processing/interpretation of the XML is at fault, why don't you try moving the relationship role with key fields to the front - rather than having the relationship role without any key fields first in the sequence of relationship role declarations in jbosscmp-jdbc.xml. At least it will match the guide's example. I'd be surprised if the sequence altered anything but if you've exhausted everything else, it is worth a shot.
-
6. Re: Error with EJB relationship
torquil May 8, 2003 1:48 AM (in response to joanwaters)In the attached .zip it looks like the relationship name is inconsistent in the two .xml files ("EMP-DEPT" and "DEPT-EMP").
Perhaps there is also a problem with your field names. As one of the other answers pointed out, when you define CMP field accessors "getBlah()" and "setBlah()", you will generate a field (on your EJB) called "blah". The field names in your code may thus be "dEPT_ID" and "eMP_ID", so you may need to change your xml accordingly.
Other than that, I can't see any obvious problem with your XML (but I'm certainly no expert).
It may be worth trying xdoclet to generate your EJB files, including the deployment descriptors. JBoss supplies an xdoclet template project (which has a few errors), and there is also an XPETSTORE sample application.
I have attached xdoclet generated xml for a one-to-many, biderectional relation, such as the one you are defining. In this model, a "ledger" has a collection of "LedgerEntries". The LedgerEntry table has a "LEDGERFK" field, specifying the foreign key of the associated ledger. The ledger EJB has a fild called "key".
Hope this helps. Good luck. -
7. Re: Error with EJB relationship
joanwaters May 8, 2003 8:40 AM (in response to joanwaters)
Thank you all for the help, Problem with relationships got corrected when I changed the case of the fields. But now I am getting the following error with the EJBQL.
This comes with 'WHERE' clause, when the this clause removed it works fine.
MBeans waiting for other MBeans:
[ObjectName: jboss.j2ee:jndiName=local/Dept,service=EJB
state: FAILED
I Depend On:
Depends On Me: org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "p.emp_id" at line 3, column 25.
Was expecting one of:
"NOT" ...
"(" ...
<COLLECTION_VALUED_PATH> ...
<STRING_VALUED_PATH> ...
"CONCAT" ...
"SUBSTRING" ...
<BOOLEAN_VALUED_PATH> ...
<DATETIME_VALUED_PATH> ...
<ENTITY_VALUED_PATH> ...
<IDENTIFICATION_VARIABLE> ...
<NUMERIC_VALUED_PATH> ...
"LENGTH" ...
"LOCATE" ...
"ABS" ...
"SQRT" ...
"+" ...
"-" ...
<INTEGER_LITERAL> ...
<FLOATING_POINT_LITERAL> ...
<NUMERIC_VALUED_PARAMETER> ...
)]
This is how the query defined.
<query-method>
<method-name>findByEmp_id</method-name>
<method-params>
<method-param>java.lang.Number</method-param>
</method-params>
</query-method>
<ejb-ql><![CDATA[
SELECT OBJECT(p)
FROM emp p
WHERE p.emp_id=?1
]]></ejb-ql> -
8. Re: Error with EJB relationship
torquil May 8, 2003 8:38 PM (in response to joanwaters)Try
SELECT OBJECT(p)
FROM emp AS p
WHERE p.emp_id=?1 -
9. Re: Error with EJB relationship
joanwaters May 17, 2003 10:16 PM (in response to joanwaters)This error comes with fields which is having data type java.lang.Number.
<method-param>java.lang.Number</method-param>
It works fine with String and Date. Is there any problem in using Number !!.