You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2008/03/04 00:27:19 UTC
svn commit: r633321 -
/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
Author: dain
Date: Mon Mar 3 15:27:12 2008
New Revision: 633321
URL: http://svn.apache.org/viewvc?rev=633321&view=rev
Log:
Applied patch for OPENEJB-750 EJB 2 Entity bean with CMP field mapped to CMR field causes ClassFormatError
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java?rev=633321&r1=633320&r2=633321&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java Mon Mar 3 15:27:12 2008
@@ -55,26 +55,26 @@
private final Class primKeyClass;
private final List<Method> selectMethods = new ArrayList<Method>();
- public Cmp2Generator(String cmpImplClass, Class beanClass, String pkField, Class<?> primKeyClass, String[] cmrFields) {
+ public Cmp2Generator(String cmpImplClass, Class beanClass, String pkField, Class<?> primKeyClass, String[] cmpFields) {
if (pkField == null && primKeyClass == null) throw new NullPointerException("Both pkField and primKeyClass are null");
beanClassName = Type.getInternalName(beanClass);
implClassName = cmpImplClass.replace('.', '/');
this.primKeyClass = primKeyClass;
- for (String cmpFieldName : cmrFields) {
+ for (String cmpFieldName : cmpFields) {
String getterName = getterName(cmpFieldName);
try {
Method getter = beanClass.getMethod(getterName);
Type type = Type.getType(getter.getReturnType());
CmpField cmpField = new CmpField(cmpFieldName, type);
- cmpFields.put(cmpFieldName, cmpField);
+ this.cmpFields.put(cmpFieldName, cmpField);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("No such property " + cmpFieldName + " defined on bean class " + beanClassName, e);
}
}
if (pkField != null) {
- this.pkField = cmpFields.get(pkField);
+ this.pkField = this.cmpFields.get(pkField);
if (this.pkField == null) {
throw new IllegalArgumentException("No such property " + pkField + " defined on bean class " + beanClassName);
}
@@ -92,6 +92,9 @@
}
public void addCmrField(CmrField cmrField) {
+ if (cmpFields.get(cmrField.getName()) != null) {
+ cmpFields.remove(cmrField.getName());
+ }
cmrFields.add(cmrField);
}
@@ -167,7 +170,7 @@
}
private void createConstructor() {
- MethodVisitor mv = mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, beanClassName, "<init>", "()V");