Problem with PK (JBoss 2.4.4)
shoffmann Mar 18, 2002 4:12 AMHi!
I have a problem with deploying Entity Beans (CMP 1.1, JBoss 2.4.4). I get the folowing error:
[ERROR,ContainerFactory]
Bean : Example
Section: 9.4.7.1
Warning: The type of the field named in the primkey-field element must match the class in the prim-key-class element.
Has anybody an idea? As far as I can see the code below should work.
Thx in advance,
Sven Hoffmann
My implementation class is:
package com.tradingfair.vtr2;
import java.rmi.*;
import javax.ejb.*;
public class Example implements EntityBean {
//my fields
public Long orderId;
public String description;
//JBoss Entity Context
private EntityContext context;
//for generating unique ids (chances are good that this does not work, but that is not the problem right now)
private static int instcnt = 0;
//Beans need a public parameterless constructor
public Example() {
}
//JBoss methods
public void setEntityContext(EntityContext aContext) {
context = aContext;
}
public void unsetEntityContext() {
context = null;
}
public Long ejbCreate() {
orderId = getNewOrderId();
return null;
}
public void ejbPostCreate() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbLoad() {
}
public void ejbStore() {
}
public void ejbRemove() {
}
//end JBoss methods
//Getter/Setter + Logic
private Long getNewOrderId() {
return new Long(++instcnt);
}
/**
* Gets the description.
* @return Returns a String
*/
public String getDescription() {
return description;
}
/**
* Sets the description.
* @param description The description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the orderId.
* @return Returns a Long
*/
public Long getOrderId() {
return orderId;
}
}
... and my ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar>
Example Entity Bean
<display-name>Example</display-name>
<enterprise-beans>
<ejb-name>Example</ejb-name>
com.tradingfair.vtr2.ExampleHome
com.tradingfair.vtr2.ExampleRemote
<ejb-class>com.tradingfair.vtr2.Example</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Long</prim-key-class>
False
<cmp-field><field-name>orderId</field-name></cmp-field>
<cmp-field><field-name>description</field-name></cmp-field>
<primkey-field>orderId</primkey-field>
<ejb-ref>
<ejb-ref-name>ejb/Property</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
com.tradingfair.vtr2.PropertyHome
com.tradingfair.vtr2.PropertyRemote
</ejb-ref>
</enterprise-beans>
</ejb-jar>