java - GAE, JPA, XG-transactions, too many entity groups exception -
i know there limit of 5 entity groups in xg-transaction on gae think using 3 groups(commodity, category, commoditycategory) in 1 transaction , still getting exception: caused by: java.lang.illegalargumentexception: operating on many entity groups in single transaction.
here vital parts of code of datamodel , dao:
category model
@entity(name = "category") public class category extends basedatastoreentity{ private string name; private key parentkey; private string parentname; @unowned @onetomany(cascade= cascadetype.all) private set<commoditycategory> commoditycategories = new hashset<commoditycategory>(); . . public void addcommoditycategoryinternal(commoditycategory commoditycategory) { this.commoditycategories.add(commoditycategory); }
commodity model
@entity(name = "commodity") public class commodity extends basedatastoreentity implements irateable{ private string name; private bigdecimal price; . . @onetomany(mappedby = "commodity", cascade= cascadetype.all, fetch= fetchtype.eager) private set<picture> pictures = new hashset<picture>(); @unowned @onetomany(cascade= cascadetype.all) private set<commoditycategory> commoditycategories = new hashset<commoditycategory>(); . . public void addcommoditycategoryinternal(commoditycategory commoditycategory) { this.commoditycategories.add(commoditycategory); }
commoditycategory model
@entity(name="commoditycategory") public class commoditycategory extends basedatastoreentity{ private boolean isdefaultcategory; @unowned @manytoone(cascade= cascadetype.all) private key commodity; @unowned @manytoone(cascade= cascadetype.all) private key category; @suppresswarnings("leakingthisinconstructor") public commoditycategory(boolean isdefaultcategory, commodity commodity, category category) { super(true); this.isdefaultcategory = isdefaultcategory; this.commodity = commodity.getid(); this.category = category.getid(); category.addcommoditycategoryinternal(this); commodity.addcommoditycategoryinternal(this); }
commoditycategory dao implementation
@repository("commoditycategorydaoimpl") public class commoditycategorydaoimpl extends abstractdao<commoditycategory, key> implements commoditycategorydao{ @override public commoditycategory create(boolean isdefaultcategory, commodity comm, category cat) { entitymanager em = emf.get().createentitymanager(); setentitymanager(em); getentitymanager().clear(); getentitymanager().gettransaction().begin(); commodity commodity = getentitymanager().find(commodity.class, comm.getid()); category category = getentitymanager().find(category.class, cat.getid()); commoditycategory commoditycategory = new commoditycategory(isdefaultcategory, commodity, category); getentitymanager().persist(commoditycategory); getentitymanager().gettransaction().commit();//here exception getentitymanager().clear(); return commoditycategory; }
any ideas why shouldn't work?
thanks answer!
pobo
i've got similar problem. try more 5 entities of same! type gae datastore , many entity groups exception. think doesnt depend on different types on amout of persistence entity. because each object of same type has different entity group. when tried in transaction of object have problem .
so getting list of entity don't use transaction anymore , works
Comments
Post a Comment