For my lookup table, I tried to create the hbm.xml file with sql-insert statements , but at the time of object creation , I get the error : Element "class" does not allow "sql-insert" here..
Why is this happening ? How can I insert data into lookup table at the time of table creation ?
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="Status" table="Status">
<id name="StatusId" column="StatusId" type="long" >
<generator class="assigned"/>
</id>
<property name="Description" column="Description" type="string"/>
<set name="accounts" cascade="all" inverse="true" lazy="true">
<key column="StatusId"/>
<one-to-many class="MWAccounts"/>
</set>
<set name="orderItems" cascade="all" inverse="true" lazy="true">
<key column="StatusId"/>
<one-to-many class="MWOrderItems"/>
</set>
<set name="orders" cascade="all" inverse="true" lazy="true">
<key column="StatusId"/>
<one-to-many class="MWOrders"/>
</set>
<sql-insert>insert into status (StatusId,Description) values(1,'Active')</sql-insert>
<sql-insert>insert into status (StatusId,Description) values(2,'Removed')</sql-insert>
</class>
</hibernate-mapping>