-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Proper order to save a hierarchal set of entities, ordered?
PostPosted: Mon Oct 29, 2007 4:08 pm 
Newbie

Joined: Mon Mar 05, 2007 5:21 am
Posts: 4
Hey all,

I've got this decl in class Survey (an entity):
Code:
   @OneToMany( cascade={ CascadeType.PERSIST, CascadeType.MERGE },
             mappedBy="survey")
   @IndexColumn(name="ORDER_IDX", base=1)
   private List<ResponseGroup> responseGroups = new ArrayList<ResponseGroup>();


But I find that ORDER_IDX is always NULL.

This is my save procedure (in a DAO that extends Spring's JpaDaoSupport):
Code:
   EntityManager em  = null;
   EntityTransaction tx;
   try {
      em = getJpaTemplate().getEntityManagerFactory().createEntityManager();
      tx = em.getTransaction();
      tx.begin();
      for (ResponseGroup rg : s.getResponseGroups()) {
         for (Response r : rg.getResponses()) {
            em.persist(r);
         }
         em.persist(rg);
      }
      em.persist(s);
      // now save the entire survey.
      tx.commit();
   } finally {
      em.close();
   }


I really need that ORDER_IDX to be set to the array indices properly. Otherwise the save works fine. Any ideas?

Btw, I'm trying to piece together the proper procedure for all this from the Hibernate book listed at the top of the page :-)... Any other resources (books, tutorials, etc) available for this kind of stuff?

Thanks in advance!

-ls


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.