Try em.refresh() before em.persist()
On Thu, Jan 13, 2011 at 6:36 PM, frank <[email protected]> wrote:
> Hello,
>
> I try to store an embedded List in an Entity.
> I runs without errors, but no elements of the List are stored
>
> Thanks for your help.
>
> here is the code:
>
> @Entity
> public class Cont implements Serializable
> {private static final long serialVersionUID = 1L;
> @Id
> @GeneratedValue(strategy = GenerationType.IDENTITY)
> private String id;
> @Extension(vendorName = "datanucleus", key = "cascade-persist",
> value = "true")
> @Embedded
> private List<Em2> em2;
>
> ..
> }
>
> @Embeddable
> public class Em2 implements Serializable
> { @Basic public String s;
> ...
> }
>
> public static String testcode()
> {
> EntityManager em = Gae.emfInstance.createEntityManager();
> Cont cont;
> List<Em2> emList = new ArrayList<Em2>();
> emList.add(new Em2("Element1"));
> emList.add(new Em2("Element2"));
>
> cont=new Cont( "1");
> cont.setEm(new Em("TEST"));
> cont.setEm2(emList);
>
> em.persist(cont);
> em.close();
>
> em = Gae.emfInstance.createEntityManager();
> Query q = em.createQuery("select c from Cont c");
> Cont read = (Cont) q.getSingleResult();
>
> System.out.println(read.getEm2().size());
> // -------------------
> // output 0
> // -------------------
>
> em.close();
> }
>
> --
> 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]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
--
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.