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: Problem with INSERTED and UPDATED column
PostPosted: Wed Jul 20, 2011 8:32 pm 
Newbie

Joined: Thu Jun 23, 2011 2:49 pm
Posts: 2
recently my product has been updated to hibernate3 from hibernate 2.8.1, we have one table in our schema called "XYZ", hibernate mapping file for the table looks like this:

<class name="a.b.c.d.Xyz" table="Xyz" >

<cache usage="read-write" />


<id name="id" type="long" column="id">
<generator class="native">
<param name="sequence">XyzService_Seq</param>
</generator>
</id>

<!-- version property used for
Hibernate managed versioning for optimistic locking -->
<version name="version" column="version" />

<!-- additional properties -->
<property name="guid" column="guid" type="string" update="false"
length="32" not-null="true" optimistic-lock="false"/>
<property name="inserted" column="inserted" type="java.util.Date"
update="false" insert="false" optimistic-lock="false"/>
<property name="updated" column="updated" type="java.util.Date"
update="false" insert="false" not-null="false" optimistic-lock="false"/>

Issue is INSERTED and UPDATED columns are not getting saved with any data when try to save a new instance of Xyz or try to update an existing instance of Xyz, any help is appreciated, it used to work fine with hibernate 2.8.1, both columns are empty everytime a new entry in created in a table or an existing entry is updated


Top
 Profile  
 
 Post subject: Re: Problem with INSERTED and UPDATED column
PostPosted: Fri Jul 22, 2011 5:41 pm 
Newbie

Joined: Fri Jul 22, 2011 5:04 pm
Posts: 8
You've mapped them with insert="false" and update="false". This tells hibernate not to include those columns in inserts or updates for that table. If you want hibernate to populate those columns for you, you need to remove insert="false" and update="false" from the <property> mappings for those columns.


Top
 Profile  
 
 Post subject: Re: Problem with INSERTED and UPDATED column
PostPosted: Sat Jul 23, 2011 2:30 am 
Newbie

Joined: Thu Jun 23, 2011 2:49 pm
Posts: 2
Thanks for reply, reason of keeping insert and update as false is:
value of inserted column is initialized from some other property [Super class] that maps to the same column(s)
value of updated column is initialized from a DB trigger

About updated column i have found the root cause and would be fixed.
For inserted column here is what the problem is, we have overwritten a org.cfg.Configuration.java in our product which does hibernate configuration and schema generation for us, there are lot of tables which have this inserted and updated columns in our product, some of them are working fine and getting populated with correct date in these two columns, some of them are not.

Reason for those who are getting NULL value for these columns is:
inserted column has a type of "timestamp".
Whereas those tables who are fine, have the type as "date"...
I read that "Hibernate cannot know if the property, which is of java.util.Date, should map to a SQL date, timestamp, or time column....."
Is there any way to make sure that type to be "date"


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.