java - Repeated column in mapping for entity, oneToMany relationship -
i trying one-to-many relationship between 2 tables. have table called users has many user_history entries. defined these tables in mysql , generated entities intellij hibrernate support. problem when want insert in databse receiving following error repeated column in mapping entity: com.userhistoryentity
user:
<?xml version='1.0' encoding='utf-8'?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.usersentity" table="users" schema="" catalog="protein_tracker"> <id name="id"> <column name="id" sql-type="int" not-null="true"/> </id> <property name="name"> <column name="name" sql-type="varchar" length="45" not-null="true"/> </property> <property name="total"> <column name="total" sql-type="int" not-null="true"/> </property> <property name="goal"> <column name="goal" sql-type="int" not-null="true"/> </property> <set name="userhistoriesbyid" inverse="true"> <key> <column name="id_user" not-null="true"/> </key> <one-to-many not-found="ignore" class="com.userhistoryentity"/> </set> </class> </hibernate-mapping> userhistory:
<?xml version='1.0' encoding='utf-8'?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.userhistoryentity" table="user_history" schema="" catalog="protein_tracker"> <id name="id"> <column name="id" sql-type="int" not-null="true"/> </id> <property name="entrydate"> <column name="entry_date" sql-type="datetime" not-null="true"/> </property> <property name="entry"> <column name="entry" sql-type="varchar" length="45" not-null="true"/> </property> <property name="iduser"> <column name="id_user" sql-type="int" not-null="true"/> </property> <many-to-one name="usersbyiduser" class="com.usersentity"> <column name="id_user" not-null="true"/> </many-to-one> </class> </hibernate-mapping> how can fix issue?
mark many-to-one mapping usersbyiduser insertable = false , updatable = false. allows relationship managed single property, iduser have mapped.
Comments
Post a Comment