K
K
KirylLapouski2017-11-17 19:23:15
MySQL
KirylLapouski, 2017-11-17 19:23:15

How to map a collection of components in hibernate?

There is a small DB schema. The Staff table is the staff, and staff_shedule is the schedule.
The program also has a Staff class and a TimeInterval class.

public class StaffEntity {
    private Integer id;
    private String fio;
    private Set shedule;
}

How to map so that the class contains a collection of type TimeInterval?
Here's what I've already done.
<hibernate-mapping>

    <class name="entity.StaffEntity" table="staff" schema="" catalog="medicine">
        <id name="id">
            <column name="id" sql-type="int unsigned" not-null="true"/>
        </id>
        <property name="fio">
            <column name="FIO" sql-type="varchar" length="100" not-null="true"/>
        </property>
       <set name="specializations" table="staff_specialization">
           <key column="id_staff"></key>
           <many-to-many class="entity.SpecialtyEntity" column="id_specialty"/>
       </set>
        <composite-element class="entity.util.TimeInterval">
            <property name="since" column="since_"/>
            <property name="to" column="to_"/>
        </composite-element>
    </class>
</hibernate-mapping>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question