-->
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: Error set datetime field
PostPosted: Fri Jun 17, 2005 10:25 am 
Newbie

Joined: Fri Jan 28, 2005 7:05 pm
Posts: 1
Hi,
I'm a total newbie to Hibernate so please bear with me. I'm reading a datetime datatype field from a Sybase database and it is not being cast correctly according to Hibernate. I've looked elsewhere for casting examples between the datetime field and other date definitions and have come up empty handed.

The definitions and error message follow:

VendorEntity.hbm.xml def for field
<property name="beginningDate" column="beginning_date" type="timestamp" not-null="false" />

Sybase table definition for field
datatype = datetime, nulls = yes

Field definition in POJO file
private java.sql.Date beginningDate;

setter method signature
setBeginningDate(java.sql.Date beginningDate)

Value passed from Sybase database that causes set method to crash
9/9/2004 8:29:45.653 AM

Stack trace follows:
VendorEntity.setBeginningDate() - date passed is: 2004-09-09 08:29:45.653 66
09:03:28,323 ERROR HibernateUtil:74 - exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of emat.com.beans.db.entity.VendorEntity.setEndingDate
DBAccess.getListResult() - throwing up here - ERROR: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of emat.com.beans.db.entity.VendorEntity.setEndingDate
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of emat.com.beans.db.entity.VendorEntity.setEndingDate
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:221)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2223)
at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:315)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at emat.com.beans.db.DBAccess.getListResult(DBAccess.java:69)
at emat.com.beans.db.entityQuery.VendorQuery.getAllVendors(VendorQuery.java:49)
at emat.com.beans.db.entity.VendorEntityTest.getAllRecords(VendorEntityTest.java:38)
at emat.com.beans.db.entity.VendorEntityTest.main(VendorEntityTest.java:27)
Caused by: net.sf.cglib.beans.BulkBeanException
at emat.com.beans.db.entity.VendorEntity$$BulkBeanByCGLIB$$337f067a.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:216)
... 13 more
Caused by: java.lang.ClassCastException
... 15 more
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of emat.com.beans.db.entity.VendorEntity.setEndingDate
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:221)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2223)
at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:315)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at emat.com.beans.db.DBAccess.getListResult(DBAccess.java:69)
at emat.com.beans.db.entityQuery.VendorQuery.getAllVendors(VendorQuery.java:49)
at emat.com.beans.db.entity.VendorEntityTest.getAllRecords(VendorEntityTest.java:38)
at emat.com.beans.db.entity.VendorEntityTest.main(VendorEntityTest.java:27)
Caused by: net.sf.cglib.beans.BulkBeanException
at emat.com.beans.db.entity.VendorEntity$$BulkBeanByCGLIB$$337f067a.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:216)
... 13 more
Caused by: java.lang.ClassCastException

I'm using Hibernate2 jar file.

The database is Sybase Adaptive Server, I don't have access to which version it is.

The JDBC driver is: JConn2

Any help would be GREATLY appreciated!


Top
 Profile  
 
 Post subject: Re: Error set datetime field
PostPosted: Fri Jun 17, 2005 11:12 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
wgblackmon wrote:
Hi,
I'm a total newbie to Hibernate so please bear with me. I'm reading a datetime datatype field from a Sybase database and it is not being cast correctly according to Hibernate. I've looked elsewhere for casting examples between the datetime field and other date definitions and have come up empty handed.

The definitions and error message follow:

VendorEntity.hbm.xml def for field
<property name="beginningDate" column="beginning_date" type="timestamp" not-null="false" />

Sybase table definition for field
datatype = datetime, nulls = yes

Field definition in POJO file
private java.sql.Date beginningDate;

setter method signature
setBeginningDate(java.sql.Date beginningDate)

Value passed from Sybase database that causes set method to crash
9/9/2004 8:29:45.653 AM

....
Any help would be GREATLY appreciated!


Since you've mapped the property as Timestamp, wouldn't it make sense for your setter method to take a java.sql.Timestamp ?


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.