I have a type table, it define animal type. Then I have another table like animal define a foregin key to link to type mkey. each time when I try to
insert data into animal table ( get object from type ), get error:
Caused by: java.sql.SQLException: Duplicate entry '1' for key 3
For animal table define:
<many-to-one name="animaltype"
class="Animaltype"
column="TYPEID"
cascade="none"
not-null="true" />
I define cascade="none" to try no effect type table. if I take off not-null="true", it can not insert typeID into animal table. How do I solve this problem?
|