Feb 15th, 2013, 09:54 AM
persistence issue master detail
First of all, congratulations for Roo. Its an amazing tool.
I am working with a master / detail like domain.
I will call the entities Master and Detail.
Master has a Set of Detail
@OneToMany(cascade = CascadeType.ALL)
private Set<Detail> detail = new HashSet<Detail>();
Detail has a Master
private Master master;
I am using HIBERNATE with MYSQL, with
<property name="hibernate.hbm2ddl.auto" value="create"/>
Starting the project, 3 tables are created in database:
When I save my Master, it goes to master table, correctly.
When I save my Detail, it goes to detail table with the correct reference to Master, in the apropriate column.
But the 3rd table (master_detail) is not getting any values.
1st question: Why the link table is not getting any values? What I am missing?
When i retrieve a master, it finds none of his details, because of this empty table (master_detail).
2nd question: Is this link table (master_detail) necessary? Since its not a m:m relationship, a column in detail could handle the relationship.
Feb 18th, 2013, 07:58 AM
a mappedBy property in @onetomay made it.
now it dont create the link table, all works fine.