Hello,
I have hit upon a really peculiar problem. I have a field where I want to store the last changed time, so I map it as type - timestamp. When I do that, while saving, it corrupts the other property values. If I change the type to - date, then it works fine, but the time of last change is not stored. The other properties are an integer and a string.
This seems a really weird issue, and I am not sure where to start debugging. I have about 10 other screens, and they all seem to work fine. Just this one alone.
Here is an interesting observation I made.
The integer property is corrupted only while creating it. Subsequent saves seems to leave it alone.
The string property(description) gets corrupted everytime, but there seems to be pattern to it. Only the first 3 letters get corrupted.
asd became ^óÀ
123asd became �asd
123asd became nq@asd
asd became ûS@asd
This is the first time I am coming across something like this in Hibernate. I hope no one else got this, but have the patience to help me debug this issue.
Hibernate version: - 3.2.6.ga
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="Branch" table="EXCEPTION_BRANCH_NUMBER">
<id name="branchNumber" type="integer">
<column name="BRANCH_NUMBER" precision="10" scale="0" />
<generator class="assigned" />
</id>
<property name="description" type="string">
<column name="DESCRIPTION" length="256" />
</property>
<property name="userId" type="string">
<column name="CHANGE_USER_ID" length="10" not-null="true" />
</property>
<property name="changeTimestamp" type="date">
<column name="CHANGE_TIMESTAMP" length="7" not-null="true" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
hibernateTemplate.saveOrUpdate(branch);
Name and version of the database you are using:
Oracle 10
Debug level Hibernate log excerpt:
2009-04-08 11:09:32,367 470797 [btpool0-1] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils - Opening Hibernate Session
2009-04-08 11:09:32,367 470797 [btpool0-1] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12392033723
2009-04-08 11:09:32,367 470797 [btpool0-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2009-04-08 11:09:32,367 470797 [btpool0-1] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2009-04-08 11:09:32,367 470797 [btpool0-1] DEBUG org.hibernate.SQL - select branch_.BRANCH_NUMBER, branch_.DESCRIPTION as DESCRIPT2_1_, branch_.CHANGE_USER_ID as CHANGE3_1_, branch_.CHANGE_TIMESTAMP as CHANGE4_1_ from EXCEPTION_BRANCH_NUMBER branch_ where branch_.BRANCH_NUMBER=?
2009-04-08 11:09:32,383 470813 [btpool0-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2009-04-08 11:09:32,383 470813 [btpool0-1] DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 333, using strategy: org.hibernate.id.Assigned
2009-04-08 11:09:32,492 470922 [btpool0-1] DEBUG com.tdsecurities.branchRevenue.admin.support.HibernateTemplate - Eagerly flushing Hibernate session
2009-04-08 11:09:32,492 470922 [btpool0-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
2009-04-08 11:09:32,492 470922 [btpool0-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
2009-04-08 11:09:32,492 470922 [btpool0-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2009-04-08 11:09:32,492 470922 [btpool0-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2009-04-08 11:09:32,492 470922 [btpool0-1] DEBUG org.hibernate.pretty.Printer - listing entities:
2009-04-08 11:09:32,508 470938 [btpool0-1] DEBUG org.hibernate.pretty.Printer - com.tdsecurities.branchRevenue.admin.models.Branch{changeTimestamp=2009-04-08 11:09:21, branchNumber=333, userId=PADINS2, description=asd}
2009-04-08 11:09:32,508 470938 [btpool0-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2009-04-08 11:09:32,508 470938 [btpool0-1] DEBUG org.hibernate.SQL - insert into EXCEPTION_BRANCH_NUMBER (DESCRIPTION, CHANGE_USER_ID, CHANGE_TIMESTAMP, BRANCH_NUMBER) values (?, ?, ?, ?)
2009-04-08 11:09:32,508 470938 [btpool0-1] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
2009-04-08 11:09:32,539 470969 [btpool0-1] DEBUG org.hibernate.jdbc.Expectations - success of batch update unknown: 0
2009-04-08 11:09:32,539 470969 [btpool0-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2009-04-08 11:09:32,539 470969 [btpool0-1] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
2009-04-08 11:09:32,539 470969 [btpool0-1] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2009-04-08 11:09:32,539 470969 [btpool0-1] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2009-04-08 11:09:49,820 488250 [btpool0-1] DEBUG org.springframework.security.ui.ExceptionTranslationFilter - Chain processed normally
2009-04-08 11:09:49,820 488250 [btpool0-1] DEBUG org.springframework.security.context.HttpSessionContextIntegrationFilter - SecurityContextHolder now cleared, as request processing completed
|