• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mapping Problem in Hibernate

 
hariharakarthi Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting the below error in Hibernate...

Initial SessionFactory creation failed.org.hibernate.PropertyNotFoundException: field [treserveFactorPK.yearNo] not found on icp.entity.TreserveFactor

My mapping doc is as follows,

<class name="icp.entity.TannualStmtLine" table="TANNUAL_STMT_LINE">
<id column="ANNUAL_STMT_LN_ID" name="annualStmtLnId" type="string">
<generator class="assigned"/>
</id>
<property name="annualStmtLnNm" type="string">
<column length="30" name="ANNUAL_STMT_LN_NM" not-null="true"/>
</property>
<property name="updateTs" type="timestamp">
<column length="45" name="UPDATE_TS" not-null="true"/>
</property>
<property name="updUserId" type="string">
<column length="8" name="UPD_USER_ID" not-null="true"/>
</property>
<property name="exceptionIn" type="char">
<column length="1" name="EXCEPTION_IN" not-null="true"/>
</property>
<property name="ovAnnlStmtLnId" type="string">
<column length="3" name="OV_ANNL_STMT_LN_ID" not-null="true"/>
</property>
<set name="treserveFactors" table="TRESERVE_FACTOR">
<key column="ANNUAL_STMT_LN_ID"/>
<composite-element class="icp.entity.TreserveFactor">
<parent name="icp.entity.TannualStmtLine"/>
<many-to-one name="measureId" class="icp.entity.Tmeasure" column="MEASURE_ID"/>
<property name ="treserveFactorPK.yearNo" column="YEAR_NO"/>
<property name ="treserveFactorPK.yearNo" column="QUARTER_NO"/>
<many-to-one name="poolCd" class="icp.entity.TpoolCompanyPK" column="POOL_CD"/>
<many-to-one name="companyNo" class="icp.entity.TpoolCompanyPK" column="COMPANY_NO"/>
<property name ="crntResrvFctrPc" column="CRNT_RESRV_FCTR_PC"/>
<property name ="min1ResrvFctrPc" column="MIN1_RESRV_FCTR_PC"/>
<property name ="min2ResrvFctrPc" column="MIN2_RESRV_FCTR_PC"/>
<property name ="min3ResrvFctrPc" column="MIN3_RESRV_FCTR_PC"/>
<property name ="min4ResrvFctrPc" column="MIN4_RESRV_FCTR_PC"/>
<property name ="updateTs" column="UPDATE_TS"/>
<property name ="updUserId" column="UPD_USER_ID"/>
<property name ="min5ResrvFctrPc" column="MIN5_RESRV_FCTR_PC"/>
</composite-element>
</set>
</class>

The table TRESERVE_FACTOR structure is as follows,

CREATE TABLE REPORTER.TRESERVE_FACTOR
(
MEASURE_ID NUMBER NOT NULL,
YEAR_NO NUMBER NOT NULL,
QUARTER_NO NUMBER(1,0) NOT NULL,
POOL_CD CHAR(8) NOT NULL,
COMPANY_NO CHAR(4) NOT NULL,
ANNUAL_STMT_LN_ID CHAR(3) NOT NULL,
CRNT_RESRV_FCTR_PC NUMBER(13,6) DEFAULT 0 NOT NULL,
MIN1_RESRV_FCTR_PC NUMBER(13,6) DEFAULT 0 NOT NULL,
MIN2_RESRV_FCTR_PC NUMBER(13,6) DEFAULT 0 NOT NULL,
MIN3_RESRV_FCTR_PC NUMBER(13,6) DEFAULT 0 NOT NULL,
MIN4_RESRV_FCTR_PC NUMBER(13,6) DEFAULT 0 NOT NULL,
UPDATE_TS DATE NOT NULL,
UPD_USER_ID CHAR(8) NOT NULL,
MIN5_RESRV_FCTR_PC NUMBER(13,6) DEFAULT 0 NOT NULL
)

PRIMARY KEY (MEASURE_ID,YEAR_NO,QUARTER_NO,POOL_CD,COMPANY_NO,ANNUAL_STMT_LN_ID)


I have created the entity class for the table TRESERVE_FACTOR using Netbeans. It created two POJOS,
TreserveFactor -- POJO for Table it has TreserveFactorPK as one of the type
TreserveFactorPK --- POJO class for Primarykeys of TRESERVE_FACTOR table

[treserveFactorPK.yearNo] not found on icp.entity.TreserveFactor --- I have given the value as "yearNo" then also it says the same problem.

Please advise..


 
Reehan Lalkhanwar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we have two fields mapped to the same property below

Moreover as treserveFactorPK is a seperate class, it would have to be mapped as a composite property or better in a seperate hbm and put a mapping here.
 
hariharakarthi Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your input. How to configure the property inside a composite-element as a composite-property.
Moreover, the TreserverFactorPK is a class generated for primary keys of the table TRESERVER_FACTOR, how to it is going to affect when I configure the TreserveFactorPK in a separate hbm file and if it is possible, then how to refer it in this above hbm file.

Thanks,
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!