Does anyone know what triggers the No Persister error:
No persister for: java.lang.Long
It is triggered on the commit. Any help would be greatly appreciated.
Thanks in advance...
try {
HibernateUtil.beginTransaction();
Session session = HibernateUtil.getSession();
actypeb.addChart(chart);
session.update(actypeb);
HibernateUtil.commitTransaction(); <--- happens here....
} catch (Exception ex) {
ex.printStackTrace();
}
Hibernate version:
2.1.7.c
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Sat Nov 20 12:25:00 GMT-06:00 2004 -->
<hibernate-mapping >
<class name="com.dygtig.actype.Actype" table="actype">
<id name="id" column="ID" >
<generator class="increment"/>
</id>
<version name="ver" column="VER" />
<property name="type" column="TYPE" not-null="true" />
<property name="model" column="MODEL" not-null="true" />
<property name="mtow" column="MTOW" not-null="true" />
<set name="cgCharts" lazy="true" inverse="true" cascade="save-update">
<key><column name="ACID" /></key>
<one-to-many class="com.dygtig.chart.Chart" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Sun Jan 16 20:32:51 GMT-06:00 2005 -->
<!-- <many-to-one name="actype" class="com.dygtig.actype.Actype" column="ACID"/> -->
<!-- <property name="acid" column="ACID" not-null="true" />
<set name="points" lazy="false" inverse="false">
<key><column name="CHARTID" /></key>
<one-to-many class="com.dygtig.chart.Point" />
</set>
-->
<hibernate-mapping >
<class name="com.dygtig.chart.Chart" table="chart">
<id name="id" column="ID" >
<generator class="increment"/>
</id>
<version name="ver" column="VER" />
<property name="type" column="TYPE" not-null="true" />
<property name="description" column="DESCRIPTION" not-null="true" />
<many-to-one name="acid" class="com.dygtig.actype.Actype" not-null="true">
<column name="ACID" />
</many-to-one>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
static {
try {
configuration = new Configuration();
sessionFactory = configuration
.configure(CONFIG_FILE_LOCATION)
.buildSessionFactory();
// We could also let Hibernate bind it to JNDI:
// configuration.configure().buildSessionFactory()
} catch (Throwable ex) {
// We have to catch Throwable, otherwise we will miss
// NoClassDefFoundError and other subclasses of Error
log.error("Building SessionFactory failed.", ex);
throw new InfrastructureException(ex);
}
}
/**
* Returns the SessionFactory used for this static class.
*
* @return SessionFactory
*/
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
/**
* Returns the original Hibernate configuration.
*
* @return Configuration
*/
/**
* Retrieves the current Session local to the thread.
* <p/>
* If no Session is open, opens a new Session for the running thread.
*
* @return Session
*/
public static Session getSession()
throws InfrastructureException {
Session s = (Session) threadSession.get();
try {
if (s == null) {
log.debug("Opening new Session for this thread.");
if (getInterceptor() != null) {
log.debug("Using interceptor: " + getInterceptor().getClass());
s = getSessionFactory().openSession(getInterceptor());
} else {
s = getSessionFactory().openSession();
}
threadSession.set(s);
}
System.out.println("Session Open");
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
return s;
}
/**
* Closes the Session local to the thread.
*/
public static void closeSession()
throws InfrastructureException {
try {
Session s = (Session) threadSession.get();
threadSession.set(null);
if (s != null && s.isOpen()) {
log.debug("Closing Session of this thread.");
s.close();
}
System.out.println("Session Closed");
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
}
/**
* Start a new database transaction.
*/
public static void beginTransaction()
throws InfrastructureException {
Transaction tx = (Transaction) threadTransaction.get();
try {
if (tx == null) {
log.debug("Starting new database transaction in this thread.");
tx = getSession().beginTransaction();
threadTransaction.set(tx);
}
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
}
/**
* Commit the database transaction.
*/
public static void commitTransaction()
throws InfrastructureException {
Transaction tx = (Transaction) threadTransaction.get();
try {
if ( tx != null && !tx.wasCommitted()
&& !tx.wasRolledBack() ) {
log.debug("Committing database transaction of this thread.");
tx.commit();
}
threadTransaction.set(null);
} catch (HibernateException ex) {
rollbackTransaction();
throw new InfrastructureException(ex);
}
}
Full stack trace of any exception that occurs:
Hibernate: select actype0_.ID as ID0_, actype0_.VER as VER0_, actype0_.TYPE as TYPE0_, actype0_.MODEL as MODEL0_, actype0_.MTOW as MTOW0_ from actype actype0_ where actype0_.ID=?
Hibernate: select cgcharts0_.ID as ID__, cgcharts0_.ACID as ACID__, cgcharts0_.ID as ID0_, cgcharts0_.VER as VER0_, cgcharts0_.TYPE as TYPE0_, cgcharts0_.DESCRIPTION as DESCRIPT4_0_, cgcharts0_.ACID as ACID0_ from chart cgcharts0_ where cgcharts0_.ACID=?
Session Closed
com.dygtig.common.InfrastructureException: net.sf.hibernate.MappingException: No persister for: java.lang.Long
at com.dygtig.hibernate.HibernateUtil.commitTransaction(HibernateUtil.java:184)
at com.dygtig.views.ACTypeChartView.finish(ACTypeChartView.java:511)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.dygtig.filters.SecurityCheckFilter.doFilter(SecurityCheckFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: net.sf.hibernate.MappingException: No persister for: java.lang.Long
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:344)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2681)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2688)
at net.sf.hibernate.impl.SessionImpl.isUnsaved(SessionImpl.java:1083)
at net.sf.hibernate.impl.SessionImpl.nullifyTransientReferences(SessionImpl.java:1029)
at net.sf.hibernate.impl.SessionImpl.nullifyTransientReferences(SessionImpl.java:1015)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:920)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:850)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:772)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1380)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
at net.sf.hibernate.impl.SessionImpl.preFlushEntities(SessionImpl.java:2664)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2239)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.dygtig.hibernate.HibernateUtil.commitTransaction(HibernateUtil.java:179)
... 31 more
Session Closed
End of Chain
Name and version of the database you are using:
MYSQL
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: