View RSS Feed

My Java Tips

  1. one-to-many, sql

    by , 06-02-2011 at 08:20 PM (My Java Tips)
    Let me presnet a simple <one-to-many> association from Parent to Child.

    XML Code:
    <set name="children">
    <key column="parent_id"/>
    <one-to-many class="Child"/>
    </set>
    Assume that we wish to execute the following code:

    Java Code:
    Parent p = .....;
    Child c = new Child();
    p.getChildren().add(c);
    session.save(c);
    session.flush();
    ...
    Tags: one-to-many Add / Edit Tags
    Categories
    Hibernate