Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1.2
Mapping documents:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Settings for a remote MSSQL database.-->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.username">sa</property>
<property name="connection.password">sa</property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.url">jdbc:jtds:sqlserver://localhost/mpc</property>
<!-- Use the C3P0 connection pool. -->
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">10</property>
<property name="c3p0.timeout">100</property>
<!-- Use the Hibernate built-in pool for tests.
<property name="connection.pool_size">1</property>
-->
<!-- Use EHCache but not the query cache. -->
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="cache.use_query_cache">false</property>
<property name="cache.use_minimal_puts">false</property>
<property name="max_fetch_depth">3</property>
<!-- Print SQL to stdout. -->
<property name="show_sql">false</property>
<property name="format_sql">false</property>
<!-- Refresh database on each build of SessionFactory and drop it on close.
<property name="hbm2ddl.auto">create</property> -->
<!-- Bind the getCurrentSession() method to the thread (don't use for EJBs) -->
<property name="current_session_context_class">thread</property>
<!-- Batch inserts are currently broken, no idea why... -->
<property name="jdbc.batch_size">25</property>
<property name="jdbc.fetch_size">100</property>
<mapping class="net.infopls.mpc.persistence.model.AgMessage" />
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
try{
sessionFactory.getCurrentSession().beginTransaction();
AgMessageDao amDao = DaoFactory.HIBERNATE.getAgMessageDao();
amDao.makePersistent(msg);
sessionFactory.getCurrentSession().getTransaction().commit();
}catch(Exception ex) {
logger.error("Exception when Save Angel Message:", ex);
sessionFactory.getCurrentSession().getTransaction().rollback();
}
Full stack trace of any exception that occurs:
Exception when Save XML Report:
java.lang.reflect.UndeclaredThrowableException
at $Proxy110.saveOrUpdate(Unknown Source)
at net.infopls.common.hibernate.dao.GenericHibernateDao.makePersistent(GenericHibernateDao.java:84)
at net.infopls.mpc.ejb3.PositioningProcessorBean.saveMlpMessage(PositioningProcessorBean.java:119)
at net.infopls.mpc.ejb3.PositioningProcessorBean.process(PositioningProcessorBean.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:178)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:74)
at $Proxy88.process(Unknown Source)
at net.infopls.mpc.http.LocationHttpService.service(LocationHttpService.java:43)
at net.infopls.common.net.http.server.HttpServerWorker.process(HttpServerWorker.java:189)
at net.infopls.common.net.http.server.HttpServerWorker$Processer.run(HttpServerWorker.java:205)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
... 32 more
Caused by: java.lang.ClassCircularityError: org/hibernate/engine/ForeignKeys$Nullifier
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:263)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:531)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:519)
... 37 more
Name and version of the database you are using:
MSSQL2000+SP4
Sometimes I saved the some record from 4 or more thread almost at same time, the exception ClassCircularityError occurred. but when I tried the same operation, the exception never occurred! I don't know WHY!