This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
Simple requirement .. but I don't know how!
Hibernate - can't get the collection (List) when create criteria
inner-join?
Hibernate: cascade deletion of a many-to-many relationship
Hibernate Delete Not Null Columns