-->
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: version column problem for value collection mapping
PostPosted: Wed May 24, 2006 10:52 am 
Newbie

Joined: Wed May 17, 2006 4:32 am
Posts: 16
i set the following mapping
Code:
<set name="images" lazy="true" table="ITEM_IMAGE"> <key column="ITEM_ID"/>
<element type="string" column="FILENAME" not-null="true"/> </set>

but for the ITEM_IMAGE i added additional versional column
Code:
<version name="version" column="VERSION" access="field"/>

when i try to save the item with the added filename it rises exception saying that version cant be null while executing the following DML
Code:
insert into ITEM_IMAGE (ITEM_ID, FILENAME) values (?, ?)

so it ignores the version column specified in the mapping


is there soulution to the problem, because i also using that ITEM_IMAGE as an entity which should have a version coulumn?[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 11:43 am 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
<version> is a tag used in association with an optimistic-locking strategy. It is generated automatically by the database in most cases. There is a "generated" property for the version that defaults to "never". You have to tell Hibernate that it will be generated by the database. There is a discussion of this in section 5.1.7 of the Reference Manual (version 3.1.1). You have not told it that the database will generate it, so it has to be filled in by some other means.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 2:22 am 
Newbie

Joined: Wed May 17, 2006 4:32 am
Posts: 16
hibernate_user wrote:
There is a "generated" property for the version that defaults to "never".

Even if i explicitly specify that property with "always" or "never" value, it still doesn't help. The DML remains the same with no mention of version field. The main point is that i want hibernate to generate that value automatically
Code:
Try to insert null into a non-nullable column: column: VERSION table: ITEM_SET_IMAGE in statement [insert into ITEM_SET_IMAGE (ITEM_ID, FILENAME) values (?, ?)]


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.