-->
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: Timestamp problem (Hibernate and MSSQL2000)
PostPosted: Thu Jul 31, 2008 5:50 am 
Newbie

Joined: Thu Jul 31, 2008 5:35 am
Posts: 2
Can someone here help me with the following situation?

I have a MSSQL 2000 Database with Timestamp columns in tables.

So hibernate generated following code for Entity Bean with byte[] type for Timestamp columns:

Code:
private byte[] timestamp;
@Version
@Column(name = "Timestamp", nullable = false)
public byte[] getTimestamp() {
   return this.timestamp;
}

public void setTimestamp(byte[] timestamp) {
   this.timestamp = timestamp;
}


As I understood it, these columns get updated automatically, but when I try to create new objects I get following exception:

Quote:
org.hibernate.PropertyValueException: not-null property references a null or transient value: de.fhg.iml.otdassist.entitybeans.otdmodel.InObject.timestamp


So, in this situation I don't try to set the Timestamp property explicit, e.g.:

Code:
        attr = new InAttribute();
        attr.setInObject(obj);
        attr.setSystemAttributeType(attrType);
        attr.setBtId(btId);
        attr.setCard(card);
        attr.setSenderId("otdnetassist");
        em.persist(attr); 


So I tried to change the column type from byte[] to java.sql.Timestamp, but I get another exception that Date can not be implicitly converted.

How I can handle these Timestamp columns, there's very few information in Hibernate Documentation, maybe it is some MS SQL 2000 problem?

Thank you in advance,
Yuri


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 01, 2008 9:47 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
It might be that the columns are not being updated automatically.

You may have to do a SchemaExport, or have the database configuration recreated when you create the Configuration object. You can set Hibernate to do this by configuring your hibernate.cfg.xml file.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.