I'm doing an hbm2java with Hibernate Tools 3.2.4.GA
I have tables like this:
Code:
create table DOG (
dog_id numeric(10) primary key,
name varchar(15) not null
);
create table BONE (
bone_id numeric(10) primary key,
dog_id numeric(10) not null,
desc varchar(15) not null,
CONSTRAINT dog_id_fk FOREIGN KEY (dog_id) REFERENCES DOG(dog_id)
);
The result in class Dog is:
Code:
private Set<Bone> bones = new HashSet<Bone>(0);
and in class B:
Code:
private Dog dog;
which is an expected default. However, I would like to FORCE that all dogs only have one bone, as that is the business policy by convention, and would prefer to not have to write code which constantly grabs the first item from a Set. I would like the Dog class to just have:
Code:
private Bone bone;
In my hibernate.reveng.xml, I have tried this:
Code:
<table name="BONE">
<foreign-key constraint-name="dog_id">
<one-to-one property="dog" exclude="false"/>
<inverse-one-to-one property="bone" exclude="false"/>
</foreign-key>
</table>
but in Dog I still get the
Set<Bone> bones and no
Bone bone-Steve
Tampa, FL