Hi, I got stuck while inserting record in a table which have a Primary key as IDENTITY column and two Foreign Key. In hbm file I have defiend mapping like this: <class name="com.ge.med.registries.acc_30.hibernate.TCx1AdmdisT" table="T_CX1_AdmDis_T"> <composite-id > <key-many-to-one name="PatientSite" class="com.ge.med.registries.acc_30.hibernate.TCx1PtsiteT"> <column name="Participant_ID" not-null="true"/> <column name="PatID" not-null="true"/> </key-many-to-one> <key-property name="admissionId"> <column name="Admission_ID" length="10"/> </key-property> </composite-id>
<property name="admitdt" column="AdmitDt" type="timestamp" length="23"/> <property name="dischdt" column="DischDt" type="timestamp" length="23"/> <set name="labVisit" inverse="true" lazy="false" cascade="all"> <key column="PatID"/> <one-to-many class="com.ge.med.registries.acc_30.hibernate.TCx1LabvisitT"/> </set> </class> while inserting record it gives me following Exception java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Cannot insert explicit value for identity column in table 'T_CX1_AdmDis_T' when IDENTITY_INSERT is set to OFF. NOTE : I get this exception only when Composite key contain one Primary key defined Identity column (auto-increment) in database. It seems to work fine with Composite Key having Primary Key which is not Identity Column. ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel