Is it in a webapplication or windows application?
create a method like this
Code:
public Boolean exists( Book book ){
/** Check here if the book exists*/
... SELECT b FROM Book b WHERE b.Id != :id AND b.Name = :Name AND b.Title = :Title;
/** add parameters here */
return true or false if we got a book
}
In this way you will be able to update the book that has this id but no new book with the same id, title and name.
Code:
public Book addBook( Book book ){
if( ! exists( book ) ){
// Add here
}
// return null or something that indicates that the book wasn't added
}
Please let me know if you need furthur help