Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Simple requirement .. but I don't know how! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Simple requirement .. but I don Watch "Simple requirement .. but I don New topic
Author

Simple requirement .. but I don't know how!

abu alfouz
Ranch Hand

Joined: Nov 20, 2006
Posts: 44
Hi All,

I work on an application that connect to database by hibernate (I use annotations). I have 2 entities (Department and Employee). Of course the Employee has one Department but the Department has many employees.

What I want is to be able to delete some Department without delete its Employees. (When deleting Department the hibernate should delete constraints that link some Employees to it without deleting the Employees).

Any help please.

Thank you.


SCJP 1.5
SCWCD 1.4
Vivek Singh
Ranch Hand

Joined: Oct 27, 2009
Posts: 92
So One Department can have Many employees.

Put Cascade as None.What is the constraint?
Employee table put department discriptor.

Post your code also sample code.
abu alfouz
Ranch Hand

Joined: Nov 20, 2006
Posts: 44
*** This is the Department class:





*** This is the Employee class:




Any help please?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple requirement .. but I don't know how!
 
Similar Threads
Hibernate Delete Not Null Columns
inner-join?
Hibernate: cascade deletion of a many-to-many relationship
Simple requirement .. but I don't know how!
Hibernate - can't get the collection (List) when create criteria