CREATE TABLE class_definition (
class_id_pk integer DEFAULT nextval('class_id_pk_seq'::text) NOT NULL,
class_name character varying(200),
class_description character varying(200)
);
INSERT INTO class_definition VALUES (1,'NonWriteAclass', 'NonWriteAclass 1');
INSERT INTO class_definition VALUES (2,'NonWriteBclass', 'NonWriteBclass 1');
INSERT INTO class_definition VALUES (3,'vegetables', 'name of vegetables');
INSERT INTO class_definition VALUES (4,'test2', 'testdesc2');
INSERT INTO class_definition VALUES (5,'Pallet', 'Pallet');
CREATE TABLE state_classes (
state_classes_id_pk
state_id_fk integer,
class_id_fk integer
);
INSERT INTO state_classes VALUES (1,3007, 1);
INSERT INTO state_classes VALUES (2,3007, 2);
INSERT INTO state_classes VALUES (3,3009, 2);
INSERT INTO state_classes VALUES (4,3009, 1);
INSERT INTO state_classes VALUES (5,3013, 1);
class_definition.hbm.xml
<hibernate-mapping>
<class name="com.skandsoft.setu.pojos.classdefinition.ClassDefinition" table="class_definition" >
<id name="classIdPk" type="int" unsaved-value="null">
<column name="class_id_pk" not-null="true"/>
<generator class="org.hibernate.id.Assigned"></generator>
</id>
<property name="className" column="class_name" type="string" unique="true" access="field" />
<property name="classDescription" column="class_description" type="string" />
<set name="stateClasses" inverse="true" cascade="all">
<key>
<column name="class_id_pk" />
</key>
<one-to-many class="com.skandsoft.setu.pojos.stateclasses.StateClasses"/>
</set>
state_classes.hbm.xml
<hibernate-mapping>
<class name="com.skandsoft.setu.pojos.stateclasses.StateClasses" table="state_classes">
<id name="stateClassesIdPk" type="java.lang.Integer" unsaved-value="null" >
<column name="state_classes_id_pk" not-null="true"/>
<generator class="org.hibernate.id.Assigned"></generator>
</id>
<many-to-one name="classDefinition" class="com.skandsoft.setu.pojos.classdefinition.ClassDefinition" not-null="true" column="class_id_fk" foreign-key="class_id_fk" cascade="all" />
</class>
</hibernate-mapping>
when we run session factory, it creates class_id_pk column in state_classes table db... which i dont want to map. becoz it is already have column with class_id_fk which is same..but i should be keep in hibernate.cfg.xml with attribute like <property name="hibernate.hbm2ddl.auto">
update
</property becoz i should update some columns...
tankq..
_
|