users@glassfish.java.net

Cannot set the parent object of a ManyToOne relation in my EJB3

From: <glassfish_at_javadesktop.org>
Date: Thu, 03 Apr 2008 04:27:51 PST

Hello,

To expose clearly my problem I'm taking 2 fake objects : a Library object and a book object...

[b]In the Library class the relation is like :[/b]

 @OneToMany(mappedBy = "library", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<Book> books;

[b]In the Book class the relation is like :[/b]

@ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "library_fk", nullable = false)
    private Library library;

[b]In my stateless session bean I want to affect a list of books that I queried from [u]an other database[/u] to my library object :[/b]
1) I do the query and get a list of books
2) Then I want to affect the library to each book [i]i.e., book.setLibrary(library)[/i] before doing the persistence on my Library object

But an exception is thrown !!, here's the stack... :

[i]Caused by: java.lang.NoSuchMethodError: fr.test.entity.Book._toplink_setlibrary(Lfr/test/entity/Library;)V
at fr.test.entity.Book.setLibrary(Unknown Source)
...[/i]

[b]I don't understand why ? Do you ?!! [/b]

[i]My environnement is :
- jdk1.6.0_04
- Sun Java System Application Server 9.1_01 (build b09d-fcs)
- Toplink[/i]

Thank you ++

Greg
[Message sent by forum member 'gdouzon' (gdouzon)]

http://forums.java.net/jive/thread.jspa?messageID=267522