-->
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.  [ 1 post ] 
Author Message
 Post subject: version where SQL type = DATE and java type = sql.Timestamp
PostPosted: Mon Jun 21, 2004 2:51 pm 
Newbie

Joined: Mon Jun 21, 2004 2:21 pm
Posts: 7
Location: New York, NY
Hi-

I'm using Hibernate 2.1.3 and having some wierd behavior when trying to use a version/timestamp for optimistic locking. JDK 1.4, OracleDialect.

I prevoiusly had the column mapped as a simple property, and everything worked fine.

The SQL datatype of the Version column is DATE, and the java type of the version is java.sql.Timestamp.

So my first attempt was to use the <timestamp> element.

<timestamp name="modifiedDate" column="MODIFIED_DATE"/>

This caused the following exception
java.lang.ClassCastException
at net.sf.hibernate.type.TimestampType.deepCopyNotNull(TimestampType.java:55)
at net.sf.hibernate.type.NullableType.deepCopy(NullableType.java:96)
at net.sf.hibernate.type.AbstractType.assemble(AbstractType.java:50)
at net.sf.hibernate.impl.CacheEntry.assemble(CacheEntry.java:54)
at net.sf.hibernate.impl.CacheEntry.assemble(CacheEntry.java:46)
at net.sf.hibernate.impl.SessionImpl.assembleCacheEntry(SessionImpl.java:2123)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2101)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1980)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1942)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.assemble(EntityType.java:130)
at net.sf.hibernate.impl.CacheEntry.assemble(CacheEntry.java:54)
at net.sf.hibernate.impl.CacheEntry.assemble(CacheEntry.java:46)
at net.sf.hibernate.impl.SessionImpl.assembleCacheEntry(SessionImpl.java:2123)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2101)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1980)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1942)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.assemble(EntityType.java:130)
at net.sf.hibernate.impl.CacheEntry.assemble(CacheEntry.java:54)
at net.sf.hibernate.impl.CacheEntry.assemble(CacheEntry.java:46)
at net.sf.hibernate.impl.SessionImpl.assembleCacheEntry(SessionImpl.java:2123)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2101)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1980)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1909)
at market.media.dao.MediaDAO.findByPrimaryKey(MediaDAO.java:40)


After reading the docs it seemed like the built in type TimestampType could not go from a SQL Date to a java.sql.Timestamp, so I attempted to implement a type that would do that, by cut/paste/editing the code from hibernate TimestampType.

<version name="modifiedDate" type="market.util.TimestampDateType" column="MODIFIED_DATE"/>

At that point I basically got the same kind of class cast exception. So I ran in a debugger with a breakpoint set in the deepCopyNotNull method of my
Type impl.

While inspecting some of the values passed in to deepCopyNotNull, I noticed that while for the most part Timestamps were being passed in.

What was troubling was in a few instances, Strings that were properties of the object, but totally unrelated to the Version were being passed in.

This seems very odd to me. Is this what is supposed to happen?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.