2

Hibernate Mapping: I have table called company and employee. company has list of employees In Employee table i have field called boolean:enable, Now, If enable=false means then the record should not added to the company employees list..How to do it.. Please any one help me.......

<class >
<id name="company_id" type="java.lang.String">
        <column name="COMPANY_ID" />
        <generator class="assigned" />
</id>
<property name="name" type="java.lang.String">
            <column name="NAME" not-null="true"/>
</property>
.
.
.
<list name="employees"
                table="employee"
                fetch="join"
                cascade="all">
                <key column="company_id"/>
                <list-index column="INDEX_IN_COMPANY"/>
                <one-to-many class="com....Employee" />

</list>
</class >

Regin Y
  • 21
  • 2

1 Answers1

0

You could do it by using Hibernate Validator. One example is shown in this link. In your case you would need an annotation at the class level (Company) that accepts two properties - employees and the enable property. The validator then validates in the isValid() method.

Community
  • 1
  • 1
Andy Dufresne
  • 6,022
  • 7
  • 63
  • 113