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>
|