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.  [ 3 posts ] 
Author Message
 Post subject: Timestamp corrupts database field
PostPosted: Thu Sep 23, 2004 6:24 am 
Newbie

Joined: Thu Sep 23, 2004 5:31 am
Posts: 2
Hibernate version: Hibernate 2.1.6

Mapping documents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="pojo.Publication" table="PUBLICATION">
<id name="publicationId" column="PUBLICATION_ID" type="string" unsaved-value="null">
<generator class="uuid.hex"/>
</id>
<property name="creationDate" column="CREATION_DATE" type="timestamp" not-null="true"/>
<property name="document" column="DOCUMENT" type="string" length="254" not-null="true"/>
<property name="queue" column="QUEUE" type="string" length="100" not-null="true"/>
<property name="action" column="ACTION" type="string" length="25" not-null="true"/>
<set name="publicationItems" lazy="false" inverse="true" cascade="all" >
<key column="PUBLICATION_ID"/>
<one-to-many class="pojo.PublicationItem"/>
</set>
</class>
</hibernate-mapping>


Name and version of the database: Oracle 8i - 8.1.7.3.0

When I try to insert a new Publication in the database, the generated primary key (uuid.hex) contains non hexadecimal characters.
When I change the type for the creationDate from "timestamp" to "date" or "time", the primary key is valid.
Since I need the full timestamp, changing the type is not really an option.

The java code to set the timestamp
----------------------------------
Date currentTime = new java.sql.Timestamp(new Date().getTime());
newPublication.setCreationDate(currentTime);
session.save(newPublication)

Example invalid key:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 11:57 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:15 am
Posts: 24
Which version of the Oracle jdbc drivers are you using, as I came across something similar myself.

The problem I found was whenever you used a post 9.2 client to connect to a 8.1.3 or lower database if you updated or inserted a date/timestamp field, a number field would get corrupted.

Solution, upgrade the database to 8.1.7.4 (or latest patch of that stream).


However, since you're using a varchar as the key, your mileage may vary on this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 27, 2004 4:10 am 
Newbie

Joined: Thu Sep 23, 2004 5:31 am
Posts: 2
Thanks a lot.

The driver I was using didn't match the actual Oracle DB version.

Oracle JDBC Driver version - 9.0.2.0.0
Oracle Version - 8.1.7.3.0

Changing the driver did solve my problem.


Kind regards.


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