-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Object creation working in junit test but not in tomcat
PostPosted: Thu Aug 04, 2005 9:30 am 
Newbie

Joined: Thu Aug 04, 2005 9:10 am
Posts: 4
Hello,

i mapped an object Qualifcation with hibernate. Qualfication is linked with User and Device. Device is linked with DeviceFamily.
Each of this 4 objects have their mapping files. To create a qualfication in database i always set firt the device and the user attribut.
This work in junit, i'm able to create a Qualification, but fail in tomcat environment.
Any direction where i could search ?

Note: the generated SQL is the one shown when a DeviceFamily, then a Device, then a Qualification is created and when the qualifcation is saved - with create method, see below.



Hibernate version:3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="fuse.domain.Qualification" table="Qualifications" lazy="false">
<cache usage="read-write" />
<id name="id" column="Qual_id" type="integer" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="title" column="Title" type="string" />
<property name="rtp" column="Rtp" type="date" />
<many-to-one name="owner" class="fuse.domain.user.User" column="userId" cascade="save-update"/>
<many-to-one name="device" class="fuse.domain.Device" column="Product_id" cascade="save-update"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

public int create(Qualification q)
{
logger.debug("Creating a new Qualification " + q);
Session s = HibernateUtil.getSession();
HibernateUtil.beginTransaction();

s.save(q);
s.flush();

HibernateUtil.commitTransaction();

int result = q.getId(); // id has been set by hibernate

return result;
}


Full stack trace of any exception that occurs:
198062 [http-8080-Processor25] ERROR fuse.command.FuseCommand - Exception catched in command : org.hibernate.exception.GenericJDBCException, could not insert: [fuse.domain.Qualification]
198093 [http-8080-Processor25] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/FUSE].[FUSE Servlet] - "Servlet.service()" pour la servlet FUSE Servlet a généré une exception
org.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:49)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:82)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:320)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at fuse.utils.hibernate.HibernateUtil.commitTransaction(Unknown Source)
at fuse.utils.hibernate.SessionManager.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
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:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
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)



Name and version of the database you are using: SQL Server

The generated SQL (show_sql=true):
Hibernate: insert into ProductsFamily (Name) values (?)
Hibernate: insert into Products (Name, Family_id) values (?, ?)
Hibernate: insert into Qualifications (Title, Rtp, userId, Product_id) values (?, ?, ?, ?)


Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 9:39 am 
Newbie

Joined: Thu Aug 04, 2005 9:10 am
Posts: 4
humm sorry for the doublon, this one can be deleted ( the other post has colors, more attractive :))


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.