Results 1 to 2 of 2

Thread: Merging and object losing OneToMany relations(in view)

  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Default Merging and object losing OneToMany relations(in view)

    I am using Spring MVC 3, JPA and Hibernate.

    I have an object A having a list of B. In domain class A I have:

    @LazyCollection(LazyCollectionOption.TRUE)
    @OneToMany
    private List<B> list_Of_B;

    When I display A on the view (jsp), everything is fine, I have the list of B.
    But then I want to save A and return to the view of A.

    Saving is done using an entity manager(in the DAO, called by a service, called by a controller):
    @PersistenceContext
    EntityManager em;
    ...
    em.merge(A);

    In controler, after we save A, we return to the same view of A.
    But this time, we lose all the list of B(just on display, the relationship exists in db).

    Do I need more annotation on the list of B ?
    Thanks in advance.

  2. #2
    Join Date
    Mar 2012
    Posts
    2

    Default em

    EntityManager.merge loses all the OneToMany

    Any work around?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •