From: Guido L. (JIRA) <no...@at...> - 2006-07-24 20:32:18
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-7?page=comments#action_23748 ] Guido Laures commented on ANN-7: -------------------------------- I agree with James and Ronald. I finally manged to get an indexed list persisted by removing the mappedBy attribute. Before this the index column was NULL permanently. But it is not correctly implemented as every indexed one-to-many association seems to result in a cross reference table, which is not necessary and produces unnessecary updates during insert. Please fix this. > @IndexColumn does not result in valid index column > -------------------------------------------------- > > Key: ANN-7 > URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-7 > Project: Hibernate Annotations > Type: Bug > Components: binder > Versions: 3.1beta3 > Environment: Hibernate 3.0.5, Hibernate Annotations 3.0 beta2 preview, HSQL DB > Reporter: Ronald Wildenberg > > > I have a mapping for a List that does not result in the index column of the database table to be filled. > @Entity > public class A { > @OneToMany(mappedBy = "a") > @Cascade(value = CascadeType.SAVE_UPDATE) > @IndexColumn(name = "index", base = 0) > public List<B> getBs() { > return bs; > } > public void setBs(List<B> bs) { > this.bs = bs; > } > } > @Entity > public class B { > > @ManyToOne(optional = false) > @JoinColumn(name = "a_id") > public A getA() { > return a; > } > public void setA(A a) { > this.a = a; > } > } > Using this mapping, the 'index' column for table B is never filled if I add B objects to A and save them. > The weird thing is, if I change the mapping for getBs to the following: > @OneToMany > @Cascade(value = CascadeType.SAVE_UPDATE) > @IndexColumn(name = "index", base = 0) > an association table is created with columns a_id, b_id, index. The only change I made is removing the mappedBy attribute. This association table is not necessary, since an index column can be added to table B. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |