-->
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: Saving with unique key
PostPosted: Mon Jul 07, 2008 11:56 am 
Newbie

Joined: Fri Jul 04, 2008 3:53 pm
Posts: 2
I'm using hibernate 3.0 with an Oracle database.
I have a WEEKS table with ID, WEEK_NUMBER, and YEAR columns. There is a unique key on (WEEK_NUMBER, YEAR). When I save a Week object, I'd like to set the week number and the year, but I will not have the week id. What I'd like is for hibernate to check whether the week exists before trying to insert it. It'd be nice if it pulled the id into the Week object. I'm utterly new to hibernate, but it seems like this is something that should be possible. Here's my xml:


<class name="businessObjects.Week" table="CNPHI_ESP_WEEK">
<id name="id" column="ID">
<generator class="increment" />
</id>
<properties name="week" unique="true">
<property name="weekNumber" column="WEEK_NUMBER" not-null="true" unique-key="WEEK_YEAR" />
<property name="year" column="YEAR" not-null="true" unique-key="WEEK_YEAR" />
</properties>
</class>


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.