I think the solution for this problem is to use cascade="none" for the item reference in SequencedItem.
ValueObject SequencedItem { - @ItemSet itemSet <-> seqItems Integer sequence range="min=1" - @Item item cascade="none" } /Patrik greatfooty wrote: > > I'm having problems with the following btdesign : > > Application MyApp { > basePackage=org.testsculpt > > Module seqitem { > > Entity ItemSet { > scaffold > String name key > - Bag<@SequencedItem> seqItems orderby="sequence asc" > cascade="all-delete-orphan" <-> itemSet > } > > ValueObject SequencedItem { > - @ItemSet itemSet <-> seqItems > Integer sequence range="min=1" > - @Item item > } > > Entity Item { > scaffold > String name key > String title > String content > > Repository ItemRepository { > findAll hint="orderBy=name, orderByAsc=true"; > } > } > } > } > > I've generated with no custom code nor additions to the generated gui and > then using the GUI i do the following: > > #1. create a few Items > #2. create an ItemSet (without including any sequencedItems) > #3. list the ItemSets and select the one just created at #2 for update > #4. as part of update i create a sequencedItem (using either of the Items > created at #1) > #5. then on trying to persist updates for the ItemSet I get the following: > > System error > (org.fornax.cartridges.sculptor.framework.errorhandling.DatabaseAccessException), > caused by: org.springframework.orm.jpa.JpaSystemException: > org.hibernate.PersistentObjectException: detached entity passed to > persist: org.testsculpt.seqitem.domain.Item; nested exception is > javax.persistence.PersistenceException: > org.hibernate.PersistentObjectException: detached entity passed to > persist: org.testsculpt.seqitem.domain.Item > > I've tried this now with sculptor 1.8 but get same problem under 1.7 > > As background to why i'm desiging the data like this, see old post: > > http://old.nabble.com/Re-ordering-a-related-List-of-entities--td26296763s17564.html > Re-ordering-a-related-List-of-entities You'll see that EntityA is > ItemSet, EntityB is Item and EntityABRelation is SequencedItem except that > I've made relation one-way 1-1 from SequencedItem to Item. > > Whenever order needs to be changed I'm intending to reorder the seqItems > by updating the 'sequence' attribute on all affected SequencedItem > instances. Haven't got to trying that yet as the above problem has me > first wondering if i can use this datastructure. Note too i've taken this > approach in preference to one suggestion which was storing an ordered list > of ids onto ItemSet - that approach would've given me a ref integrity > problem when trying to remove an Item that may be ref'd within multiple > ItemSets. > > The custom ui for this item re-ordering is to be a richfaces listshuttle > as per: > > > http://livedemo.exadel.com/richfaces-demo/richfaces/listShuttle.jsf;jsessionid=C54CFAEDFE2FB0DFFD479E3DD69E6019?c=listShuttle&tab=usage > ListShuttle > > In fact once I've managed to use sculptor for this I'd ideally like to > bundle up this functionality to somehow introduce a new domain generation > pattern for auto-creation of such a sequencing entity (similar to present > many-many resolver but with a seq value included). I have many other > scenarios where the same pattern is needed. > > Any suggestions gratefully accepted re the persistence problem OR any > other approaches that you could see to modelling the data to suit the > listshuttle. > > -- View this message in context: http://old.nabble.com/-Sculptor--detached-entity-passed-to-persist--tp27648394s17564p27676883.html Sent from the Fornax-Platform mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Fornax-developer mailing list Fornax-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fornax-developer