I have 3 tables
A (
ID NUMBER(19)
FIELD VARCHAR2(255)
primary key (ID)
)
B (
ID NUMBER(19),
NAME VARCHAR2(255)
primary key (ID)
)
C (
ID NUMBER(19)
VERSION NUMBER(10)
primary key (ID, VERSION)
)
A's primary key is genereated by my own id generator, and B's primary key is the same with A's. SO B in fact is reference to A to get its primary key. and C is a composite key(ID, VERSION), "ID" will reference to table B's key "ID".
I have class for A, B, C, and C's composite primary key class CKey
Mapping file
A.hbm.xml
<id name="id" type="long" unsaved-value="null">
<generator class="MyIDGenerator" />
</id>
<one-to-one name="b" class="B" />
B.hbm.xml
<id name="id" type="long">
<generator class="foreign" >
<param name="property">variableInstance</param>
</generator>
</id>
<one-to-one name="a" class="A" constrained="true"/>
<set name="test1Set" >
<key column="ID" />
<one-to-many class="C" />
</set>
C.hbm.xml
<composite-id name="ckey" class="CKey" >
<key-property name="version" type="integer" column="VERSION"/>
<key-many-to-one name="id" class="B" column="ID" />
</composite-id>
<many-to-one name="b" class="B" update="false" insert="false" access="property" not-null="true" column="ID" />
I am sure that A and B's mapping is correct, because the data did insert into table A and B, but for the mapping of B and C I am not sure, because I got the error of "no persistent for" error.
Code before session open and session close
Code:
A a = new A();
//and set id to A by some other codes.
B b = new B();
b.setA(a);
persistenceSession.save(B);
//initiate C and PK class
C c = new C();
CKey key = new Ckey();
test2.setB(b);
key.setId(b.getId());
key.setVersion(new Integer(1));
I got the error : (
Code:
net.sf.hibernate.MappingException) No persister for: java.lang.Long
at org.jbpm.persistence.hibernate.HibernateSession.commitTransaction(HibernateSession.java:66)
at org.jbpm.impl.ExecutionServiceImpl.startProcessInstance(ExecutionServiceImpl.java:132)
at org.jbpm.web.struts.action.TaskFormSubmitAction.execute(TaskFormSubmitAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482
DO I did something wrong here? I initiate my composite key manually here. But still got the error. Could anyone help me?