Hey everyone,
My application has a very simple object model: a parent and a child entity.
I can insert and update the parent identity, however, I get a
Code:
MappingException No persister for java.lang.Long
exception whenever I try to insert a child entity.
Hibernate receives all object properties (parent id, child properties and the child id is determined as well).
Actually, I guess this not a difficult problem, but I did not find anything in the forum or in the documentation which helps me any further.
<br />
Any hint or help is highly appreciated!!!
Hibernate version: Hibernate 2
Mapping documents:The parent entity:
Code:
<hibernate-mapping>
<class name = "de.Platinion.rr.QuestGen.P200038_26.BusinessLogic.DTOP200038_26"
table = "MAIN">
<id name="id" type="java.lang.Long" column="ID">
<generator class="increment"/>
</id>
<property name="interviewpartner"/>
<property name="position"/>
<property name="email"/>
<property name="telephone"/>
<property name="date"/>
<property name="appName"/>
<property name="status" type="de.Platinion.rr.QuestGen.DataTypes.StatusUserType"/>
<set name = "interfaces"
lazy = "true">
<key column="MAIN_ID"/>
<one-to-many class="de.Platinion.rr.QuestGen.P200038_26.BusinessLogic.DTOP200038_26_Interfaces"/>
</set>
</class>
</hibernate-mapping>
The child entity:
Code:
<hibernate-mapping>
<class name = "de.Platinion.rr.QuestGen.P200038_26.BusinessLogic.DTOP200038_26_Interfaces"
table = "INTERFACES">
<id name="id" type="java.lang.Long" column="CHILD_ID">
<generator class="increment"/>
</id>
<property name="interface"/>
<property name="comment"/>
<property name="direction" type="de.Platinion.rr.QuestGen.DataTypes.StatusUserType"/>
<many-to-one name = "mainId"
class = "de.Platinion.rr.QuestGen.P200038_26.BusinessLogic.DTOP200038_26"
column = "MAIN_ID"
cascade = "delete"
not-null = "true"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
...
public void insertChildData(DTOP200038_26_Interfaces pDTO)
throws Exception {
Session lSession = HibernateUtil.currentSession();
// get a transaction
Transaction lTransaction = lSession.beginTransaction();
// save the obtained data transfer object
lSession.save(pDTO);
lTransaction.commit();
// close the session
HibernateUtil.closeSession();
}
Full stack trace of any exception that occurs:Code:
javax.servlet.ServletException: No persister for: java.lang.Long
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:516)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:423)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
net.sf.hibernate.MappingException: No persister for: java.lang.Long
net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
net.sf.hibernate.impl.SessionImpl.isUnsaved(SessionImpl.java:1091)
net.sf.hibernate.impl.SessionImpl.nullifyTransientReferences(SessionImpl.java:1037)
net.sf.hibernate.impl.SessionImpl.nullifyTransientReferences(SessionImpl.java:1023)
net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:927)
net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779)
net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
de.Platinion.rr.QuestGen.P200038_26.BusinessLogic.InsertInterfacesService.insertChildData(InsertInterfacesService.java:47)
de.Platinion.rr.QuestGen.P200038_26.Presentation.action.InsertInterfacesAction.execute(InsertInterfacesAction.java:69)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Name and version of the database you are using:
MySql, 4.0.21