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