It's not a secret anymore!*
The moose likes Groovy and the fly likes disassociate 2 domain objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "disassociate 2 domain objects" Watch "disassociate 2 domain objects" New topic

disassociate 2 domain objects

Maharaj thak

Joined: Jul 29, 2010
Posts: 27
Hi All
I have 2 domain classes

class Book{
String name

Author author

class Author{
String name


Now if I do

Author bookAuthor=new Author("BOOk Author").save()
Book book1=new Book(name:"first book",author:bookAuthor).save()
Book book2=new Book(name:"second book",author:bookAuthor).save()
Book book3=new Book(name:"third book",author:bookAuthor).save()

Can I do something like this

so that I disassociate the book fro its author without deleting it from the database

Maharaj Thak
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

Yes, but only if you define author as nullable in the book constraints. And vice versa for Author. You'll want to make book nullable.

GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

When posting code, please remember to UseCodeTags. Our system makes non-formatted code really difficult to read.
I agree. Here's the link:
subject: disassociate 2 domain objects
Similar Threads
newbee cant find string
create multiple Checkboxes with data base values in jsp
Explation of Object Identity
java code problem
EJB 3.0 Entity Bean