hibernate foreign key mapping many-to-one

Posted by Lily on Stack Overflow See other posts from Stack Overflow or by Lily
Published on 2010-03-23T21:34:03Z Indexed on 2010/03/23 21:43 UTC
Read the original article Hit count: 431

I have been working on it for quite a while, but still can't figure out what's wrong with my code. Each Service has multiple profiles, but each profile only has one Service.

Service
{
Long service_id; // primary key
... getter/setter
}

Profile
{
Long profile_id; // primary key
Long service_id; // foreign key
... getter and setter
}

in Profile.hbm.xml. I add

< many-to-one name="service_id" class="com.mot.diva.dto.Service" column="SERVICE_ID" cascade="save-update">
< /many-to-one>

Is it the correct way to map it?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about map