File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

disassociate 2 domain objects

 
Maharaj thak
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

book3.author=null

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


Regards
Maharaj Thak
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When posting code, please remember to UseCodeTags. Our system makes non-formatted code really difficult to read.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic