I\'m trying to set up a bidirectional relationship using JPA. I understand that it\'s the responsability of the application to maintain both sides of the relationship.
Try to set the fetch type association property to eager on the OneToMany side. Indeed, you may leave this part (this.library.getBooks().add(this)) to be written within a session:
Library l = new Library();
Book b = new Book();
b.setLibrary(l);
l.getBooks().add(b);