web services - Marshalling Error: failed to lazily initialize a collection of role (...), no session or session was closed -


i`m using eclipse rcp ejb exposed webservices. services beans looks follows

@override @suppresswarnings("unchecked") public list<author> listall() {     final query query = this.entitymanager.createquery("from author");     final list<author> authors = query.getresultlist();     return authors; } 

the 2 entityes are:

@entity @table(name = "books") public class book implements serializable {  @id private int id;  private string title;  private string summary;  private string isbn;  @column(name = "published") private date publishingdate;  @column(name = "created") private date createdat;  @column(name = "updated") private date modifiedat;  @manytomany @jointable(         name = "book_authors",         joincolumns = @joincolumn(name = "book_id", referencedcolumnname = "id"),         inversejoincolumns = @joincolumn(name = "author_id", referencedcolumnname = "id")) private list<author> authors; 

and

@entity @table(name = "authors") public class author implements serializable { private static final long serialversionuid = 1l;  @id private int id;  @column(name = "first_name") private string firstname;  @column(name = "middle_name") private string middlename;  @column(name = "last_name") private string lastname;  @column(name = "created") private date createdat;  @column(name = "updated") private date modifiedat;  @manytomany @jointable(         name = "book_authors",         joincolumns = @joincolumn(name = "author_id", referencedcolumnname = "id"),         inversejoincolumns = @joincolumn(name = "book_id", referencedcolumnname = "id")) private list<book> books; 

in testwsclient i`m trying

authorservicebeanservicelocator locator = new authorservicebeanservicelocator();      authorservicebean service = locator.getauthorservicebeanport();      author[] authors = service.listall();      for(author : authors){         system.out.println(a.getfirstname());     } 

and i`m getting error

{....//xml.apache.org/axis/}stacktrace:marshalling error: failed lazily initialize collection of role: ro.cgs.entities.author.books, no session or session closed

i`m mention if not make many-to-many relationship works fine. can tell me should fix problem ? use hibernate persistence. thanks.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -