| Author |
How to solve Repeated column in mapping for entity:
|
walter wang
Ranch Hand
Joined: Jun 02, 2001
Posts: 144
|
|
Dear All Could Anyone could throw some hints for me to solve Repeated column in mapping for entity problem ? My Database design is like below( could not change , it is from others) Table Clubs have Table Employees and Employeers through foreign primary key refereneced and depat_id are repeated , For mapping file of Club, i must set , insert and update to false. at lease for either Employeer or Employee. otherwise it will have repeated colum exception for Hibernate. but if i set eiter one for update and insert to false. i could not insert or update this record. How to solve this problem? Actually i just need Club to overwrite depat_id colum. How to do it with Hibernate? Thanks in advance for your input <many-to-one name="employeer" class="org.hibernate.test.Employeer" not-null="true" insert="false" update="false" > CREATE TABLE EMPLOYEES ( depat_id int NOT NULL , employee_id int NOT NULL, salary decimal(20,4) NOT NULL, primary key (depat_id,employee_id) ) CREATE TABLE EMPLOYEERS ( depat_id int NOT NULL , employeer_id int NOT NULL, salary decimal(20,4) NOT NULL, primary key (depat_id,employeer_id) ) CREATE TABLE CLUBS( club_id int NOT NULL PRIMARY KEY, depat_id int NOT NULL , employee_id int NOT NULL, employeer_id int NOT NULL, foreign key (employee_id, depat_id) references employees (depat_id,employee_id), foreign key (employeer_id, depat_id) references employeers (depat_id,employeer_id) ) <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <!-- Created by the Middlegen Hibernate plugin 2.1 http://boss.bekk.no/boss/middlegen/ http://www.hibernate.org/ --> <class name="org.hibernate.test.Club" table="CLUBS" > <meta attribute="class-description" inherit="false"> @hibernate.class table="CLUBS" </meta> <id name="clubId" type="java.lang.Integer" column="CLUB_ID" > <meta attribute="field-description"> @hibernate.id generator-class="assigned" type="java.lang.Integer" column="CLUB_ID" </meta> <generator class="assigned" /> </id> <!-- Associations --> <!-- bi-directional many-to-one association to Employee --> <many-to-one name="employee" class="org.hibernate.test.Employee" not-null="true" insert="true" update="true" > <meta attribute="field-description"> @hibernate.many-to-one not-null="true" @hibernate.column name="EMPLOYEE_ID" @hibernate.column name="DEPAT_ID" </meta> <column name="EMPLOYEE_ID" /> <column name="DEPAT_ID" /> </many-to-one> <!-- bi-directional many-to-one association to Employeer --> <many-to-one name="employeer" class="org.hibernate.test.Employeer" not-null="true" insert="false" update="false" > <meta attribute="field-description"> @hibernate.many-to-one not-null="true" @hibernate.column name="EMPLOYEER_ID" @hibernate.column name="DEPAT_ID" </meta> <column name="EMPLOYEER_ID" /> <column name="DEPAT_ID" /> </many-to-one> </class> </hibernate-mapping>
|
public class Walter{
public boolean is_Working_Now(boolean is_boss_Coming){
return is_boss_Coming;
}
|
 |
Arun Kumarr
Ranch Hand
Joined: May 16, 2005
Posts: 504
|
|
|
try to have a update="false" insert="false" in <many-to-one>.
|
If you are not laughing at yourself, then you just didn't get the joke.
|
 |
 |
|
|
subject: How to solve Repeated column in mapping for entity:
|
|
|