I cannot retreive the List<subjects> from book. The save and update of a 
book when a subject changes its fine, the problem is when retreiving books, 
It doeesnt retreive their subjects. I need help. Here;s the code.

@Entity
@Table(name = "book")
public class Book implements Serializable, IsSerializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key id;
    private String bookName;
    private String comment;
    @OneToMany(mappedBy="book",cascade = CascadeType.ALL)
    private List<Subject> subjects;

//setters and getters
--------------------------------------------------------------------------------------

@Entity
@Table(name = "subject")
public class Subject implements Serializable, IsSerializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key id;
    private String name;
    private int visible;
    @Basic
    private Text content;
    @Basic
    @ManyToOne
    private Book book;
// setters and getters

----------------------------------------------------------------------------------------------------

 public List<Book> getBooks() throws GeneralException, 
BookNotFoundException, NullParameterException {
        entityManager = EMF.get().createEntityManager();
        List<Book> list;
         try {
            String sql = "SELECT b FROM Book b";
            list = 
entityManager.createQuery(sql).getResultList();              //this list is 
retreived with the books but without their subjects
        } catch (Exception e) {
            throw new GeneralException("Exception in method getBookes: " + 
e.getMessage());
        } finally {
            if (entityManager.isOpen()) {
                entityManager.close();
            }
        }
        if (list == null || list.isEmpty()) {

            throw new BookNotFoundException("Book not found in method 
getBookes");
        }
        return list;
    }


Please, I need some help.

Cheers.

--
Kido.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to