-->
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: sql.Timestamp made smaller in Criteria Query
PostPosted: Fri Jul 27, 2007 12:18 pm 
Newbie

Joined: Fri Jul 27, 2007 4:39 am
Posts: 7
I have a problem when I try to execute a criteria query on the ids of one of my entities.

When doing a Criteria.list() I can observe only a short date being sent in the select statement (2007-03-23 11:01:00), but I have set a full timestamp object in the criteria (2007-03-23 11:01:00.465465).

I have tried to reduce the information to the essential. I hope I did not strip too much.

This is the code I am using to create the criteria.
Code:
DetachedCriteria c = DetachedCriteria.forClass(Table.class);
c.add(Restrictions.eq("id.akz", new Integer(237601150)));
c.add(Restrictions.eq("id.oid", Timestamp.valueOf("2007-03-23 11:01:00.465465")));

The select statement looks good:
Code:
select
    this_.AKZ as AKZ40_0_,
    this_.OID as OID2_40_0_,
    ...
from
    SCHEMA.TABLE this_
where
    this_.AKZ=?
    and this_.OID=?

But the binding of the parameters is strange:
Code:
hibernate.type.IntegerType - binding '237601150' to parameter: 1
hibernate.type.TimestampType - binding '2007-03-23 11:01:00' to parameter: 2

The mapping document for this class contains the following composite key:
Code:
<composite-id name="id" class="TableId">
    <key-property name="akz" type="int">
        <column name="AKZ" />
    </key-property>
    <key-property name="oid" type="timestamp">
        <column name="OID" length="26" />
    </key-property>
</composite-id>


In the POJO of the id, the property oid has the type of java.util.Date.

I am running this on a DB2, version 8.2.

I hope somebody can help me with this.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 27, 2007 12:24 pm 
Newbie

Joined: Fri Jul 27, 2007 4:39 am
Posts: 7
Sorry ... I believe this is my mistake. The statement is correctly sent to the DB, but only the output of the JDBC parameter is wrong. The query did not result in the right objects because my other SQL client somehow does not correctly read DB2 timestamp values. The stored timestamp was not 2007-03-23 11:01:00.465465 but really 2007-03-23 11:01:00.465000.

Thanks though for reading.

Is there a way to change the format for the bound parameters?


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.