Hi here is the Hibernate Environment iam using..
Hibernate version:2.1
Mapping documents:
CswCaseParent1.hbm.xml
CswChild1.hbm.xml
Code:
public static Session currentSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null) {
if (sessionFactory == null) {
try {
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
}
catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
session = sessionFactory.openSession();
threadLocal.set(session);
}
return session;
}
Full stack trace of any exception that occurs:
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: collection foreign key mapping has wrong number of columns: ****.viewpaymentsdisb.datatransfer.CswCaseParent1.cswChild1Set type: ****.viewpaymentsdisb.datatransfer.CswCaseParent1Key
at net.sf.hibernate.mapping.Collection.validate(Collection.java:248)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:626)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:790)
Name and version of the database you are using:
Oracle 9.1
code for CswCaseParent1.hbm.xml looks like this
Code:
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Wed Sep 07 16:56:45 EDT 2005 -->
<hibernate-mapping package="****.viewpaymentsdisb.datatransfer">
<class name="CswCaseParent1" table="CSWDBA.CSW_CASE_PARENT_1">
<composite-id name="id" class="CswCaseParent1Key">
<key-property name="caseId" column="CASE_ID" type="java.lang.String"/>
<key-property name="countyCd" column="COUNTY_CD" type="java.lang.String"/>
</composite-id>
<property name="clientSsnId" column="CLIENT_SSN_ID" type="java.lang.String" />
<property name="pinId" column="PIN_ID" type="java.lang.String" not-null="true" />
<property name="clientPinId" column="CLIENT_PIN_ID" type="java.lang.String" not-null="true" />
<property name="clientNm" column="CLIENT_NM" type="java.lang.String" />
<property name="netDueAmt" column="NET_DUE_AMT" type="java.lang.Double" not-null="true" />
<property name="respondentBirthDt" column="RESPONDENT_BIRTH_DT" type="java.util.Date" />
<property name="respondentAddressTypeCd" column="RESPONDENT_ADDRESS_TYPE_CD" type="java.lang.String" />
<property name="respondentUpdateSsnId" column="RESPONDENT_UPDATE_SSN_ID" type="java.lang.String" />
<property name="paymentFromDt" column="PAYMENT_FROM_DT" type="java.util.Date" not-null="true" />
<property name="paymentToDt" column="PAYMENT_TO_DT" type="java.util.Date" not-null="true" />
<property name="respondentSsnId" column="RESPONDENT_SSN_ID" type="java.lang.String" />
<property name="respondentPinId" column="RESPONDENT_PIN_ID" type="java.lang.String" not-null="true" />
<property name="respondentNm" column="RESPONDENT_NM" type="java.lang.String" />
<property name="createDt" column="CREATE_DT" type="java.util.Date" not-null="true" />
<property name="modifyDt" column="MODIFY_DT" type="java.util.Date" />
<property name="controlCycleNbr" column="CONTROL_CYCLE_NBR" type="java.lang.Integer" not-null="true" />
<property name="ncpUpdateDt" column="NCP_UPDATE_DT" type="java.util.Date" />
<set name="cswChild1Set" inverse="true">
<key column="CASE_ID"/>
<one-to-many class="****.viewpaymentsdisb.datatransfer.CswChild1"/>
</set>
</class>
</hibernate-mapping>
code for CswChild1.hbm.xml looks like this
Code:
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Wed Sep 07 17:14:09 EDT 2005 -->
<hibernate-mapping package="****.viewpaymentsdisb.datatransfer">
<class name="CswChild1" table="CSW_CHILD_1">
<id name="childId" column="CHILD_ID" type="java.lang.Long">
<generator class="hilo"/>
</id>
<property name="childFirstNm" column="CHILD_FIRST_NM" type="java.lang.String" />
<property name="childMiNm" column="CHILD_MI_NM" type="java.lang.String" />
<property name="childLastNm" column="CHILD_LAST_NM" type="java.lang.String" />
<property name="childBirthDt" column="CHILD_BIRTH_DT" type="java.util.Date" />
<property name="createDt" column="CREATE_DT" type="java.util.Date" not-null="true" />
<property name="modifyDt" column="MODIFY_DT" type="java.util.Date" />
<property name="medicalInsuranceId" column="MEDICAL_INSURANCE_ID" type="java.lang.Long" />
<many-to-one
name="cswCaseParent1"
class="****.viewpaymentsdisb.datatransfer.CswCaseParent1"
not-null="true"
update="false"
insert="false">
<column name="CASE_ID"/>
<column name="COUNTY_CD"/>
</many-to-one>
</class>
</hibernate-mapping>
I Guess i problem with the following code in CswCaseParent1.hbm.xml
Code:
<set name="cswChild1Set" inverse="true">
<key column="CASE_ID"/>
<one-to-many class="****.viewpaymentsdisb.datatransfer.CswChild1"/>
</set>
But iam unable to resolve this..SOme one please help me..
Thanks In Advance
JD