Results 1 to 2 of 2

Thread: persistence issue master detail

  1. #1
    Join Date
    Feb 2013
    Posts
    10

    Default 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
    @ManyToOne
    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:
    master
    detail
    master_detail

    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.

  2. #2
    Join Date
    Feb 2013
    Posts
    10

    Default

    a mappedBy property in @onetomay made it.
    now it dont create the link table, all works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •