Hibernate version:
2.1.3
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">
<hibernate-mapping>
<class
name="net.lidotech.biceps.domain.Activity"
table="activity"
dynamic-update="false"
dynamic-insert="false"
mutable="true"
>
<id
name="id"
column="activity_id"
type="long"
>
<generator class="native">
</generator>
</id>
<version
name="domainVersion"
type="long"
column="domain_version"
/>
<many-to-one
name="task"
class="net.lidotech.biceps.domain.Task"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="task_id"
not-null="true"
/>
<property
name="closureComment"
type="java.lang.String"
update="true"
insert="true"
column="closure_comment"
length="255"
not-null="true"
unique="false"
/>
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="description"
length="255"
not-null="true"
unique="false"
/>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name"
length="55"
not-null="true"
unique="true"
/>
<property
name="status"
type="net.lidotech.biceps.domain.enum.ActivityStatus"
update="true"
insert="true"
column="status"
not-null="true"
unique="false"
/>
this property works wrong: Code:
<property
name="endDate"
type="long"
update="true"
insert="true"
column="end_date"
not-null="true"
unique="false"
/>
Code:
<property
name="timeStamp"
type="java.util.Date"
update="true"
insert="true"
column="timestamp"
not-null="true"
unique="false"
/>
<property
name="userLogin"
type="java.lang.String"
update="true"
insert="true"
column="user_login"
length="55"
not-null="true"
unique="false"
/>
</class>
</hibernate-mapping>
Name and version of the database you are using:
MSSQL Server 8.0
Debug level Hibernate log excerpt:
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.SQL - update activity set domain_version=?, task_id=?, closure_comment=?, description=?, name=?, status=?, end_date=?, timestamp=?, user_login=? where activity_id=? and domain_version=?
Hibernate: update activity set domain_version=?, task_id=?, closure_comment=?, description=?, name=?, status=?, end_date=?, timestamp=?, user_login=? where activity_id=? and domain_version=?
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.persister.EntityPersister - Dehydrating entity: [net.lidotech.biceps.domain.Activity#157]
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.LongType - binding '1' to parameter: 1
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.engine.Cascades - version unsaved-value strategy UNDEFINED
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.engine.Cascades - id unsaved-value: 0
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.LongType - binding '17' to parameter: 2
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.StringType - binding ' ' to parameter: 3
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.StringType - binding ' 5656' to parameter: 4
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.StringType - binding '5656 ' to parameter: 5
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.PersistentEnumType - binding '3' to parameter: 6
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.LongType - binding
'1096322400000' to parameter: 7
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.TimestampType - binding '28 wrzesień 2004 10:01:21' to parameter: 8
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.StringType - binding 'bieprz1' to parameter: 9
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.LongType - binding '157' to parameter: 10
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.type.LongType - binding '0' to parameter: 11
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - post flush
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.transaction.JDBCTransaction - commit
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - flushing session
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - Flushing entities and processing referenced collections
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - Processing unreferenced collections
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - Scheduling collection removes/(re)creates/updates
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.Printer - listing entities:
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.Printer - net.lidotech.biceps.domain.Activity{timeStamp=28 wrzesień 2004 10:01:21, closureComment= , userLogin=bieprz1, description= 5656, endDate=
1096322400000, status=3, domainVersion=1, task=Task#17, name=5656 , id=157}
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.Printer - net.lidotech.biceps.domain.AuditInfo{timeStamp=28 wrzesień 2004 10:01:21, activity=Activity#4, recordId=157, auditInfoOperation=2, userLogin=bieprz1, description= , domainVersion=0, tableName=activity, id=2020}
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - executing flush
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - post flush
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.transaction.JDBCTransaction - re-enabling autocommit
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - closing session
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - disconnecting session
2004-09-28 10:01:21,781 [main ] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion
2004-09-28 10:01:21,796 [Finalizer ] DEBUG net.sf.hibernate.impl.SessionImpl - running Session.finalize()
Question:
As you can see expected value that shoud be written into persistent layer is
1096322400000. Unfortunately in database I can see
1105739520. In my application there are many properties (long type) that are stored correctly. Only in this domain object there is a problem (the most annoying thing is that it works ok in some combination of operations). Moreover this part (without any change) works correctly with Oracle (in every case).
Question is very simple:
What is wrong? How to manage this problem? Is it a problem with Hibernate Dialect (I've tried net.sf.hibernate.dialect.SybaseDialect and net.sf.hibernate.dialect.SQLServerDialect)?
I would appreciate any advice and/or hint.
Best regards