[
https://jira.jboss.org/jira/browse/JBAS-6597?page=com.atlassian.jira.plug...
]
Alexey Loubyansky commented on JBAS-6597:
-----------------------------------------
Have you tried w/o primkey-field in ejb-jar.xml?
The primkey-field element is not used if the primary key maps to
multiple container-managed fields (i.e. the key is a compound key). In
this case, the fields of the primary key class must be public, and
their names must correspond to the field names of the entity bean
class that comprise the key.
CMP findByPrimaryKey() broken for composite primary keys
--------------------------------------------------------
Key: JBAS-6597
URL:
https://jira.jboss.org/jira/browse/JBAS-6597
Project: JBoss Application Server
Issue Type: Patch
Security Level: Public(Everyone can see)
Components: CMP service
Affects Versions: JBossAS-5.0.0.CR1
Environment: Windows, JBoss 5.0.0CR1
Reporter: Markus Cozowicz
Assignee: Alexey Loubyansky
Fix For: JBossAS-5.0.0.CR1
findByPrimaryKey() in CMP for an entity bean will re-use the first property as query
parameter of a composite primary key for all fields in the SQL query. Our code worked in
JBoss 3.2.3 and got broken in 5.0.0CR1.
In ejb-jar.xml we have
- prim-key-class
- primkey-field
the prim-key-class exposes 3 properties (1 string, 2 integers). Through tracing and
debugging we saw that the query gets constructed and parameter types are inferred
correctly.
We compared QueryParameter.java from 3.2.3, 5.0.0 CR1 and v85552 (trunk as of today) and
think that functionality got lost (please not the additional "else" for the
"property != null" case. We therefore propose the following patch (which at
least solved our problem):
http://anonsvn.jboss.org/repos/jbossas/trunk/server/src/main/org/jboss/ej...
--- QueryParameter.java (Revision 85552)
+++ QueryParameter.java (Arbeitskopie)
@@ -320,10 +320,18 @@
}
arg = field.getPrimaryKeyValue(arg);
- // use mapper
- final JDBCType jdbcType = field.getJDBCType();
- arg = jdbcType.getColumnValue(0, arg);
- param = jdbcType.getParameterSetter()[0];
+ if(property != null)
+ {
+ arg = property.getColumnValue(arg);
+ param = property.getParameterSetter();
+ }
+ else
+ {
+ // use mapper
+ final JDBCType jdbcType = field.getJDBCType();
+ arg = jdbcType.getColumnValue(0, arg);
+ param = jdbcType.getParameterSetter()[0];
+ }
}
else if(property != null)
{
(this was original created here:
https://jira.jboss.org/jira/browse/ASPATCH-411)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira