-->
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.  [ 4 posts ] 
Author Message
 Post subject: Bad Long value written to MSSQL database
PostPosted: Tue Sep 28, 2004 4:50 am 
Newbie

Joined: Tue Sep 28, 2004 4:19 am
Posts: 4
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 28, 2004 5:16 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
The binary values of your values look like this:

1105739520: 1000001111010000011111100000000
1096322400000:
1111111101000001111010000011111100000000

Looks like somewhere your value goes through an int or Integer and is being truncated to 32 bits.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 30, 2004 8:18 am 
jTDS Developer
jTDS Developer

Joined: Tue Feb 24, 2004 5:36 pm
Posts: 70
Location: Bucharest, Romania
Have you tried a different JDBC driver? Maybe that's causing the truncation.

Alin.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 30, 2004 8:21 am 
Newbie

Joined: Tue Sep 28, 2004 4:19 am
Posts: 4
It was JDBC driver - it seems that i was using driver for Oracle 9.x (filename is the same: classes12.zip). I downloaded driver for Oracle 8.x and now it works - thanks guys.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.