Hi,
I've found issue when using JPA and trying to update OneToMany relation.
Ex. having User and Items (User can have multiple Items) and trying to
clear all items and then add new items, it results in empty items list when
object is fetched again.
Here's Java code:
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
User user = em.find(User.*class*, userId);
Item item1 = *new* Item("Tomatoe", 20.0d);
Item item2 = *new* Item("Carrot", 15.0d);
user.getItems().clear();
*//em.flush();* *// WORKAROUND: Flush "clear" *
* // operation to be executed in proper order*
user.addItem(item1);
user.addItem(item2);
tx.commit();
em.close();
* //em.find(User.class, userId); - it will result User with empty
"items"*
Looks it may be related to DataNucleus bug fixed in v.3.2.1
(http://www.datanucleus.org/news/access_platform_3_2_1.html)
I've described this issue:
*http://startup-with-gae.blogspot.com/2015/05/google-app-engine-onetomany-update.html*
<http://startup-with-gae.blogspot.com/2015/05/google-app-engine-onetomany-update.html>
regards,
Maciej Arkit
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/37255502-c7ea-43e2-8573-60f682802f3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.