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: How to map SQL datetime to persistent class?
PostPosted: Wed Sep 08, 2004 8:39 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 7:48 am
Posts: 21
Hi all,
I am facing a problem in getting the time value from the persistent class.
In DB the type is datetime (8) and I have mapped that column to a property of type java.sql.Date, but when I try to print the time value (from persistent class ) it prints 24.00 (i.e, it is taking a constant value of 12 am ).
So how to get time value from the persistent store (DB) into the persistent class. Is there any specific tag(XDoclet) to get the time value in my Persistent class?.




Hibernate version:2.1.2

Mapping documents:

<?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="com.systec.lifetec.labs.valueobjects.LabUnitTestResultVO"
table="lab_unit_test_result"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="unitTestResultID"
column="unit_test_result_id"
type="int"
unsaved-value="0"
>
<generator class="identity">
</generator>
</id>

<property
name="unitNumber"
type="java.lang.String"
update="true"
insert="true"
column="unit_number"
/>

<property
name="fdaNumber"
type="java.lang.String"
update="true"
insert="true"
column="fda_number"
/>

<property
name="resultCode"
type="java.lang.String"
update="true"
insert="true"
column="result_code"
/>

<property
name="testCode"
type="java.lang.String"
update="true"
insert="true"
column="test_code"
/>

<property
name="uploadDate"
type="java.sql.Date"
update="true"
insert="true"
column="upload_date"
/>

<property
name="equipmentCode"
type="java.lang.String"
update="true"
insert="true"
column="equipment_code"
/>

<property
name="dateStamp"
type="java.sql.Date"
update="true"
insert="true"
column="datestamp"
/>

<property
name="enteredBy"
type="java.lang.String"
update="true"
insert="true"
column="entered_by"
not-null="true"
/>

<property
name="isReinstated"
type="boolean"
update="true"
insert="true"
column="is_reinstated"
not-null="true"
/>

<property
name="userID"
type="java.lang.String"
update="true"
insert="true"
column="updt_userid"
not-null="true"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-LabUnitTestResultVO.xml
containing the additional properties and place it in your merge dir.
-->
</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:SQL Server 2000

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 6:51 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Have you tried using java.sql.Timestamp?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 12:39 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 7:48 am
Posts: 21
gpani wrote:
Have you tried using java.sql.Timestamp?



No, java.sql.Timestamp is used for optimistic locking and the column I am refering to is not at all related to optimistic locking


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 12:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Negative. Timestamp is nothing to do with optimistic locking. Read the javadoc.


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.