Hello,
I want to update a detached Element(in a JBOSS Environment). That did not work without any errormessage.
So now I reload the element, and save it in the same session with the same result. I tried session.update too.
What could be the problem?
Hibernate version:
3.0.5
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="de.test.pps.VoAbteilung2" table="ABTEILUNG2" >
<meta attribute="class-description">Repräsentiert eine Abteilung in der Test Datenbank</meta>
<id name="voAbteilung2Key" column="dbKey" type="integer" length="4">
<generator class="native"></generator>
</id>
<natural-id>
<property name="mandant" type="integer" not-null="false" column="mandant" length="4" />
<property name="abteilungsnummer" type="integer" not-null="true" column="abteilungsnummer" length="4" />
</natural-id>
<version name="version" column="version"></version>
<property name="name" type="string" not-null="true" column="ABTEILUNGSNAME" length="20" />
</class>
<query name="de.test.pps.getMaxAbteilungsNummer">
<![CDATA[select max(abt.abteilungsnummer) from de.test.pps.VoAbteilung2 as abt where abt.mandant = :mandant]]>
</query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Session session = getSessionFactory().getCurrentSession();
tx=session.beginTransaction();
List abtList = session.createCriteria(VoAbteilung2.class).add(
Restrictions.eq("mandant", neu.getMandant())).add(
Restrictions.eq("abteilungsnummer", neu.getAbteilungsnummer())).list();
alt=(VoAbteilung2) abtList.get(0);
alt.setName(neu.getName());
session.save(alt);
tx.commit();
session.close();
Full stack trace of any exception that occurs:
Name and version of the database you are using:
HSQL 1.8.0 or Mysql 4.0.21
The generated SQL (show_sql=true):
Update 0: update ABTEILUNG2 set version=?, ABTEILUNGSNAME=? where dbKey=? and version=?
Debug level Hibernate log excerpt:
2005-07-14 10:27:07,854 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/HibernateFactory2
2005-07-14 10:27:07,854 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=4028821a05146b6d0105146b70490000
2005-07-14 10:27:07,854 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2005-07-14 10:27:07,854 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4592966155689984
2005-07-14 10:27:07,925 DEBUG [org.hibernate.transaction.JTATransaction] begin
2005-07-14 10:27:07,925 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
2005-07-14 10:27:07,925 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2005-07-14 10:27:07,925 DEBUG [org.hibernate.SQL] select this_.dbKey as dbKey0_, this_.version as version0_0_, this_.mandant as mandant0_0_, this_.abteilungsnummer as abteilun4_0_0_, this_.ABTEILUNGSNAME as ABTEILUN5_0_0_ from ABTEILUNG2 this_ where this_.mandant=? and this_.abteilungsnummer=?
2005-07-14 10:27:07,925 INFO [STDOUT] Hibernate: select this_.dbKey as dbKey0_, this_.version as version0_0_, this_.mandant as mandant0_0_, this_.abteilungsnummer as abteilun4_0_0_, this_.ABTEILUNGSNAME as ABTEILUN5_0_0_ from ABTEILUNG2 this_ where this_.mandant=? and this_.abteilungsnummer=?
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.IntegerType] binding '1' to parameter: 1
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.IntegerType] binding '1' to parameter: 2
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2005-07-14 10:27:07,925 DEBUG [org.hibernate.loader.Loader] processing result set
2005-07-14 10:27:07,925 DEBUG [org.hibernate.loader.Loader] result set row: 0
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.IntegerType] returning '1' as column: dbKey0_
2005-07-14 10:27:07,925 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[de.test.pps.VoAbteilung2#1]
2005-07-14 10:27:07,925 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [de.test.pps.VoAbteilung2#1]
2005-07-14 10:27:07,925 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Hydrating entity: [de.test.pps.VoAbteilung2#1]
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.IntegerType] returning '0' as column: version0_0_
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.IntegerType] returning '1' as column: mandant0_0_
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.IntegerType] returning '1' as column: abteilun4_0_0_
2005-07-14 10:27:07,925 DEBUG [org.hibernate.type.StringType] returning 'neu' as column: ABTEILUN5_0_0_
2005-07-14 10:27:07,925 DEBUG [org.hibernate.engine.TwoPhaseLoad] Version: 0
2005-07-14 10:27:07,925 DEBUG [org.hibernate.loader.Loader] done processing result set (1 rows)
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2005-07-14 10:27:07,925 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2005-07-14 10:27:07,925 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 1
2005-07-14 10:27:07,925 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [de.test.pps.VoAbteilung2#1]
2005-07-14 10:27:07,925 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [de.test.pps.VoAbteilung2#1]
2005-07-14 10:27:07,925 DEBUG [org.hibernate.engine.PersistenceContext] initializing non-lazy collections
2005-07-14 10:27:07,935 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] ignoring persistent instance
2005-07-14 10:27:07,935 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] object already associated with session: [de.test.pps.VoAbteilung2#1]
2005-07-14 10:27:07,935 DEBUG [org.hibernate.transaction.JTATransaction] commit
2005-07-14 10:27:07,935 DEBUG [org.hibernate.impl.SessionImpl] closing session
2005-07-14 10:27:07,935 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction before completion callback
2005-07-14 10:27:07,935 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically flushing session
2005-07-14 10:27:07,935 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2005-07-14 10:27:07,935 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2005-07-14 10:27:07,935 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2005-07-14 10:27:07,935 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 3
2005-07-14 10:27:07,935 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2005-07-14 10:27:07,935 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
|