Hi
Please follow this.
1.........In JP_SUMMARY table u hvae two columns called : SUM_POLNUM and SUM_COMPANYCODE .
And these two u r using as composite key .
......that is why u r declaring like <composite-id>......... </composite-id> JP_SUMMARY.hbm.xml file.
but y r u using this code.. JP_SUMMARY.hbm.xml (This is u have to use if and only if the foreign key is in JP_SUMMARY table...but urs is another case....that is foreigh key is available in JP_NOTES table...).
<set name="jpNotes" lazy="true" inverse="true" cascade="all">
<key>
<column name="SUM_POLNUM" />
<column name="SUM_COMPANYCODE" />
</key>
<one-to-many
class="com.ifs.app.model.adaptors.JpNotesAdaptor" />
</set>
Please tell me the reason why u r using this code......in JP_SUMMARY.hbm.xml
here u r specifying two columns and it is refering to class="com.ifs.app.model.adaptors.JpNotesAdaptor
but those fields are not available in JpNotesAdaptor .
that is why it is giving that error.
. 2. ..... And this composite key is present in JP_NOTES table as a foreignKey.
according to this point foreign key is available in
JP_NOTES ...
this means u need to specify the <set>.....</set> in JP_NOTES hbm file.
but u have specified in JP_SUMMARY.hbm.xml
Solutuion is as follows....
1. Remove the <set>.....</set> JP_SUMMARY.hbm.xml .
2.add the following code in JP_NOTES.hbm.xml file.
<set name="jpSummary" lazy="true" inverse="true" cascade="all">
<key>
<column name="SUM_POLNUM" />
<column name="SUM_COMPANYCODE" />
</key>
<one-to-many
class="com.ifs.app.model.adaptors.JpSummaryAdaptor" />
</set>
dont forget to remove the following code from JP_NOTES.hbm.xml file.
<column name="SUM_POLNUM"></column>
<column name="SUM_COMPANYCODE"></column>
Please try this and let me know if there is any problem............
debapriya wrote:
Hi Purnachandra,
I am giving u my details u just guide me how to resolve this error.
I have two tables :
1)JP_SUMMARY 2)JP_NOTES
In JP_SUMMARY table i hvae two columns called : SUM_POLNUM and SUM_COMPANYCODE .And these two i am using as composite key .
And this composite key is present in JP_NOTES table as a foreignKey.
For Composite key i have written a separate class called "JpSummaryPolComp".The code is given below:
package com.ifs.app.model.entities;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
public class JpSummaryPolComp extends com.ifs.app.model.BaseDomain implements
Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String sumPolnum;
private String sumCompanycode;
public JpSummaryPolComp(String sumPolnum, String sumCompanycode) {
this.sumPolnum = sumPolnum;
this.sumCompanycode = sumCompanycode;
}
public JpSummaryPolComp() {
}
public String getSumPolnum() {
return this.sumPolnum;
}
public void setSumPolnum(String sumPolnum) {
this.sumPolnum = sumPolnum;
}
public String getSumCompanycode() {
return this.sumCompanycode;
}
public void setSumCompanycode(String sumCompanycode) {
this.sumCompanycode = sumCompanycode;
}
public boolean equals(Object other) {
if ((this == other))
return true;
if (!(other instanceof JpSummaryPolComp))
return false;
JpSummaryPolComp castOther = (JpSummaryPolComp) other;
return new EqualsBuilder().append(this.getSumPolnum(),
castOther.getSumPolnum()).isEquals();
}
public int hashCode() {
return new HashCodeBuilder().append(getSumPolnum()).toHashCode();
}
}
Now the hbms for the JP_SUMMARY and JP_NOTES table are given below:
JpSummary.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ifs.app.model.adaptors.JpSummaryAdaptor"
table="jp_summary" lazy="true">
<composite-id name="policyNum"
class="com.ifs.app.model.adaptors.JpSummaryPolCompAdaptor">
<key-property name="sumPolnum" type="java.lang.String"
column="SUM_POLNUM" />
<key-property name="sumCompanycode" type="java.lang.String"
column="SUM_COMPANYCODE" />
</composite-id> <property name="sumDateaction" type="java.sql.Timestamp"
column="SUM_DATEACTION" not-null="false" length="10" />
<property name="sumEffdate" type="java.sql.Timestamp"
column="SUM_EFFDATE" not-null="false" length="10" />
<property name="sumEntrydate" type="java.sql.Timestamp"
column="SUM_ENTRYDATE" not-null="false" length="10" />
<property name="sumReceivedDate" type="java.sql.Timestamp"
column="SUM_RECEIVED_DATE" not-null="false" length="10" />
<property name="sumAppState" type="java.lang.String"
column="SUM_APP_STATE" not-null="false" length="30" />
<property name="sumAppCountry" type="java.lang.String"
column="SUM_APP_COUNTRY" not-null="false" length="30" />
<property name="sumAgentcode" type="java.lang.String"
column="SUM_AGENTCODE" not-null="false" length="40" />
<property name="sumAgencyCode" type="java.lang.String"
column="SUM_AGENCY_CODE" not-null="false" length="40" />
<property name="sumUndwrid" type="java.lang.String"
column="SUM_UNDWRID" not-null="false" length="20" />
<property name="sumCsr" type="java.lang.String" column="SUM_CSR"
not-null="false" length="20" />
<property name="sumRegion" type="java.lang.String"
column="SUM_REGION" not-null="false" length="10" />
<property name="sumTeam" type="java.lang.String"
column="SUM_TEAM" not-null="false" length="10" />
<property name="sumStatus" type="java.lang.String"
column="SUM_STATUS" not-null="true" length="3" />
<property name="sumCloseDate" type="java.sql.Timestamp"
column="SUM_CLOSE_DATE" not-null="false" length="10" />
<property name="sumOrg1" type="java.lang.String"
column="SUM_ORG1" not-null="false" length="60" />
<property name="sumOrg2" type="java.lang.String"
column="SUM_ORG2" not-null="false" length="60" />
<property name="sumOrg3" type="java.lang.String"
column="SUM_ORG3" not-null="false" length="60" />
<property name="sumOrg4" type="java.lang.String"
column="SUM_ORG4" not-null="false" length="60" />
<property name="sumReferto" type="java.lang.String"
column="SUM_REFERTO" not-null="false" length="20" />
<property name="sumCounterDecl" type="java.lang.String"
column="SUM_COUNTER_DECL" not-null="false" length="3" />
<property name="sumCurrCode" type="java.lang.String"
column="SUM_CURR_CODE" not-null="false" length="1" />
<property name="sumArchived" type="java.lang.String"
column="SUM_ARCHIVED" not-null="false" length="1" />
<property name="sumAppType" type="java.lang.String"
column="SUM_APP_TYPE" not-null="false" length="3" />
<property name="sumReinsureCode" type="java.lang.String"
column="SUM_REINSURE_CODE" not-null="false" length="3" />
<property name="sumInvTrgDate" type="java.sql.Timestamp"
column="SUM_INV_TRG_DATE" not-null="false" length="10" />
<property name="sumMailedDate" type="java.sql.Timestamp"
column="SUM_MAILED_DATE" not-null="false" length="10" />
<property name="sumLob" type="java.lang.String" column="SUM_LOB"
not-null="false" length="5" />
<property name="sumMrktDist" type="java.lang.String"
column="SUM_MRKT_DIST" not-null="false" length="5" />
<property name="sumMainframeDate" type="java.sql.Timestamp"
column="SUM_MAINFRAME_DATE" not-null="false" length="10" />
<property name="sumUndwrTeam" type="java.lang.String"
column="SUM_UNDWR_TEAM" not-null="false" length="5" />
<property name="sumEntryCode" type="java.lang.String"
column="SUM_ENTRY_CODE" not-null="false" length="3" />
<property name="sumOriginCde" type="java.lang.String"
column="SUM_ORIGIN_CDE" not-null="false" length="3" />
<property name="hostKey" type="java.lang.String"
column="HOST_KEY" not-null="false" length="60" />
<property name="amountAtRisk" type="java.lang.Float"
column="AMOUNT_AT_RISK" not-null="false" length="8" />
<property name="conversionAmount" type="java.lang.Float"
column="CONVERSION_AMOUNT" not-null="false" length="8" />
<property name="mecindicator" type="java.lang.String"
column="MECINDICATOR" not-null="false" length="1" />
<property name="unisex" type="java.lang.String" column="UNISEX"
not-null="false" length="1" />
<property name="marketSegment" type="java.lang.String"
column="MARKET_SEGMENT" not-null="false" length="5" />
<property name="marketProgram" type="java.lang.String"
column="MARKET_PROGRAM" not-null="false" length="5" />
<property name="mktSegmntVerbage" type="java.lang.String"
column="MKT_SEGMNT_VERBAGE" not-null="false" length="60" />
<property name="prbFundElection" type="java.lang.String"
column="PRB_FUND_ELECTION" not-null="false" length="1" />
<property name="dcaFundElection" type="java.lang.String"
column="DCA_FUND_ELECTION" not-null="false" length="1" />
<property name="dmdpFundElection" type="java.lang.String"
column="DMDP_FUND_ELECTION" not-null="false" length="1" />
<property name="reinsuranceAccepted" type="java.lang.String"
column="REINSURANCE_ACCEPTED" not-null="false" length="1" />
<property name="enteredBy" type="java.lang.String"
column="ENTERED_BY" not-null="false" length="20" />
<property name="applicationNo" type="java.lang.String"
column="APPLICATION_NO" not-null="false" length="40" />
<property name="applicationId" type="java.lang.String"
column="APPLICATION_ID" not-null="false" length="40" />
<property name="illustrationCode" type="java.lang.String"
column="ILLUSTRATION_CODE" not-null="false" length="5" />
<property name="sumOriginLoc" type="java.lang.String"
column="SUM_ORIGIN_LOC" not-null="false" length="3" />
<!-- <property name="policynum"
type="com.ifs.app.model.adaptors.JpSummaryPolCompAdaptor"
insert="false" update="false" access="field" /> -->
<set name="jpNotes" lazy="true" inverse="true" cascade="all">
<key>
<column name="SUM_POLNUM" />
<column name="SUM_COMPANYCODE" />
</key>
<one-to-many
class="com.ifs.app.model.adaptors.JpNotesAdaptor" />
</set> </class>
</hibernate-mapping>
JpNotes.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ifs.app.model.adaptors.JpNotesAdaptor"
table="jp_notes" lazy="true">
<id name="recordKey" type="java.lang.String"
column="record_key">
<generator class="increment" />
</id>
<property name="noteDate" type="java.sql.Timestamp"
column="NOTE_DATE" not-null="true" length="10" />
<property name="insuredId" type="java.lang.Integer"
column="INSURED_ID" not-null="true" length="11" />
<property name="userId" type="java.lang.String" column="USER_ID"
not-null="true" length="20" />
<property name="note" type="java.lang.String" column="note"
not-null="false" length="25" />
<property name="viewExternal" type="java.lang.String"
column="view_external" not-null="false" length="1" />
<many-to-one name="jpSummary"
class="com.ifs.app.model.adaptors.JpSummaryAdaptor" insert="false"
update="false" not-null="true">
<column name="SUM_POLNUM"></column>
<column name="SUM_COMPANYCODE"></column>
</many-to-one> <many-to-one name="jpNotesDesc"
class="com.ifs.app.model.adaptors.JpNotesDescAdaptor"
not-null="true">
<column name="NOTE_CODE" />
</many-to-one>
<!--
<many-to-one name="companyCode" class="com.ifs.app.model.adaptors.JpSummaryAdaptor" not-null="true">
<column name="COMPANY_CODE"/>
</many-to-one>
-->
</class>
</hibernate-mapping>
Entity for these two are given below:
JpSummary.java
In this JpSummary entity i have that composite class called "JpSummaryPolComp".You can see the first private property.And see the last private property i have one Set of jpNotes.In my code when i am trying to get a Set of JpNotes from JpSummaryAdaptor its throwing me error.
package com.ifs.app.model.entities;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.Set;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class JpSummary extends com.ifs.app.model.BaseDomain implements Serializable {
//
// private String sumCompanycode;
private com.ifs.app.model.entities.JpSummaryPolComp policyNum;
private Timestamp sumDateaction;
private Timestamp sumEffdate;
private Timestamp sumEntrydate;
private Timestamp sumReceivedDate;
private String sumAppState;
private String sumAppCountry;
private String sumAgentcode;
private String sumAgencyCode;
private String sumUndwrid;
private String sumCsr;
private String sumRegion;
private String sumTeam;
private String sumStatus;
private Timestamp sumCloseDate;
private String sumOrg1;
private String sumOrg2;
private String sumOrg3;
private String sumOrg4;
private String sumReferto;
private String sumCounterDecl;
private String sumCurrCode;
private String sumArchived;
private String sumAppType;
private String sumReinsureCode;
private Timestamp sumInvTrgDate;
private Timestamp sumMailedDate;
private String sumLob;
private String sumMrktDist;
private Timestamp sumMainframeDate;
private String sumUndwrTeam;
private String sumEntryCode;
private String sumOriginCde;
private String hostKey;
private Float amountAtRisk;
private Float conversionAmount;
private String mecindicator;
private String unisex;
private String marketSegment;
private String marketProgram;
private String mktSegmntVerbage;
private String prbFundElection;
private String dcaFundElection;
private String dmdpFundElection;
private String reinsuranceAccepted;
private String enteredBy;
private String applicationNo;
private String applicationId;
private String illustrationCode;
private String sumOriginLoc;
// private String SumPolnumsumCompanycode;
private Set jpNotes;
/** full constructor */
public JpSummary(com.ifs.app.model.entities.JpSummaryPolComp policyNum, Timestamp sumDateaction, Timestamp sumEffdate, Timestamp sumEntrydate, Timestamp sumReceivedDate, String sumAppState, String sumAppCountry, String sumAgentcode, String sumAgencyCode, String sumUndwrid, String sumCsr, String sumRegion, String sumTeam, String sumStatus, Timestamp sumCloseDate, String sumOrg1, String sumOrg2, String sumOrg3, String sumOrg4, String sumReferto, String sumCounterDecl, String sumCurrCode, String sumArchived, String sumAppType, String sumReinsureCode, Timestamp sumInvTrgDate, Timestamp sumMailedDate, String sumLob, String sumMrktDist, Timestamp sumMainframeDate, String sumUndwrTeam, String sumEntryCode, String sumOriginCde, String hostKey, Float amountAtRisk, Float conversionAmount, String mecindicator, String unisex, String marketSegment, String marketProgram, String mktSegmntVerbage, String prbFundElection, String dcaFundElection, String dmdpFundElection, String reinsuranceAccepted, String enteredBy, String applicationNo, String applicationId, String illustrationCode, String sumOriginLoc, Set jpNotes){
// this.sumPolnum = sumPolnum;
this.policyNum = policyNum;
this.sumDateaction = sumDateaction;
this.sumEffdate = sumEffdate;
this.sumEntrydate = sumEntrydate;
this.sumReceivedDate = sumReceivedDate;
this.sumAppState = sumAppState;
this.sumAppCountry = sumAppCountry;
this.sumAgentcode = sumAgentcode;
this.sumAgencyCode = sumAgencyCode;
this.sumUndwrid = sumUndwrid;
this.sumCsr = sumCsr;
this.sumRegion = sumRegion;
this.sumTeam = sumTeam;
this.sumStatus = sumStatus;
this.sumCloseDate = sumCloseDate;
this.sumOrg1 = sumOrg1;
this.sumOrg2 = sumOrg2;
this.sumOrg3 = sumOrg3;
this.sumOrg4 = sumOrg4;
this.sumReferto = sumReferto;
this.sumCounterDecl = sumCounterDecl;
this.sumCurrCode = sumCurrCode;
this.sumArchived = sumArchived;
// this.sumCompanycode = sumCompanycode;
this.sumAppType = sumAppType;
this.sumReinsureCode = sumReinsureCode;
this.sumInvTrgDate = sumInvTrgDate;
this.sumMailedDate = sumMailedDate;
this.sumLob = sumLob;
this.sumMrktDist = sumMrktDist;
this.sumMainframeDate = sumMainframeDate;
this.sumUndwrTeam = sumUndwrTeam;
this.sumEntryCode = sumEntryCode;
this.sumOriginCde = sumOriginCde;
this.hostKey = hostKey;
this.amountAtRisk = amountAtRisk;
this.conversionAmount = conversionAmount;
this.mecindicator = mecindicator;
this.unisex = unisex;
this.marketSegment = marketSegment;
this.marketProgram = marketProgram;
this.mktSegmntVerbage = mktSegmntVerbage;
this.prbFundElection = prbFundElection;
this.dcaFundElection = dcaFundElection;
this.dmdpFundElection = dmdpFundElection;
this.reinsuranceAccepted = reinsuranceAccepted;
this.enteredBy = enteredBy;
this.applicationNo = applicationNo;
this.applicationId = applicationId;
this.illustrationCode = illustrationCode;
this.sumOriginLoc = sumOriginLoc;
this.jpNotes = jpNotes;
}
/** default constructor */
public JpSummary(){
}
/** minimal constructor */
public JpSummary(String sumStatus, Set jpNotes,com.ifs.app.model.entities.JpSummaryPolComp policyNum){
// this.sumPolnum = sumPolnum;
this.sumStatus = sumStatus;
// this.sumCompanycode = sumCompanycode;
this.jpNotes = jpNotes;
this.policyNum = policyNum;
}
//
// public String getSumPolnum() {
// return this.sumPolnum;
// }
//
// public void setSumPolnum(String sumPolnum) {
// this.sumPolnum = sumPolnum;
// }
public Timestamp getSumDateaction() {
return this.sumDateaction;
}
public void setSumDateaction(Timestamp sumDateaction) {
this.sumDateaction = sumDateaction;
}
public Timestamp getSumEffdate() {
return this.sumEffdate;
}
public void setSumEffdate(Timestamp sumEffdate) {
this.sumEffdate = sumEffdate;
}
public Timestamp getSumEntrydate() {
return this.sumEntrydate;
}
public void setSumEntrydate(Timestamp sumEntrydate) {
this.sumEntrydate = sumEntrydate;
}
public Timestamp getSumReceivedDate() {
return this.sumReceivedDate;
}
public void setSumReceivedDate(Timestamp sumReceivedDate) {
this.sumReceivedDate = sumReceivedDate;
}
public String getSumAppState() {
return this.sumAppState;
}
public void setSumAppState(String sumAppState) {
this.sumAppState = sumAppState;
}
public String getSumAppCountry() {
return this.sumAppCountry;
}
public void setSumAppCountry(String sumAppCountry) {
this.sumAppCountry = sumAppCountry;
}
public String getSumAgentcode() {
return this.sumAgentcode;
}
public void setSumAgentcode(String sumAgentcode) {
this.sumAgentcode = sumAgentcode;
}
public String getSumAgencyCode() {
return this.sumAgencyCode;
}
public void setSumAgencyCode(String sumAgencyCode) {
this.sumAgencyCode = sumAgencyCode;
}
public String getSumUndwrid() {
return this.sumUndwrid;
}
public void setSumUndwrid(String sumUndwrid) {
this.sumUndwrid = sumUndwrid;
}
public String getSumCsr() {
return this.sumCsr;
}
public void setSumCsr(String sumCsr) {
this.sumCsr = sumCsr;
}
public String getSumRegion() {
return this.sumRegion;
}
public void setSumRegion(String sumRegion) {
this.sumRegion = sumRegion;
}
public String getSumTeam() {
return this.sumTeam;
}
public void setSumTeam(String sumTeam) {
this.sumTeam = sumTeam;
}
public String getSumStatus() {
return this.sumStatus;
}
public void setSumStatus(String sumStatus) {
this.sumStatus = sumStatus;
}
public Timestamp getSumCloseDate() {
return this.sumCloseDate;
}
public void setSumCloseDate(Timestamp sumCloseDate) {
this.sumCloseDate = sumCloseDate;
}
public String getSumOrg1() {
return this.sumOrg1;
}
public void setSumOrg1(String sumOrg1) {
this.sumOrg1 = sumOrg1;
}
public String getSumOrg2() {
return this.sumOrg2;
}
public void setSumOrg2(String sumOrg2) {
this.sumOrg2 = sumOrg2;
}
public String getSumOrg3() {
return this.sumOrg3;
}
public void setSumOrg3(String sumOrg3) {
this.sumOrg3 = sumOrg3;
}
public String getSumOrg4() {
return this.sumOrg4;
}
public void setSumOrg4(String sumOrg4) {
this.sumOrg4 = sumOrg4;
}
public String getSumReferto() {
return this.sumReferto;
}
public void setSumReferto(String sumReferto) {
this.sumReferto = sumReferto;
}
public String getSumCounterDecl() {
return this.sumCounterDecl;
}
public void setSumCounterDecl(String sumCounterDecl) {
this.sumCounterDecl = sumCounterDecl;
}
public String getSumCurrCode() {
return this.sumCurrCode;
}
public void setSumCurrCode(String sumCurrCode) {
this.sumCurrCode = sumCurrCode;
}
public String getSumArchived() {
return this.sumArchived;
}
public void setSumArchived(String sumArchived) {
this.sumArchived = sumArchived;
}
// public String getSumCompanycode() {
// return this.sumCompanycode;
// }
//
// public void setSumCompanycode(String sumCompanycode) {
// this.sumCompanycode = sumCompanycode;
// }
public String getSumAppType() {
return this.sumAppType;
}
public void setSumAppType(String sumAppType) {
this.sumAppType = sumAppType;
}
public String getSumReinsureCode() {
return this.sumReinsureCode;
}
public void setSumReinsureCode(String sumReinsureCode) {
this.sumReinsureCode = sumReinsureCode;
}
public Timestamp getSumInvTrgDate() {
return this.sumInvTrgDate;
}
public void setSumInvTrgDate(Timestamp sumInvTrgDate) {
this.sumInvTrgDate = sumInvTrgDate;
}
public Timestamp getSumMailedDate() {
return this.sumMailedDate;
}
public void setSumMailedDate(Timestamp sumMailedDate) {
this.sumMailedDate = sumMailedDate;
}
public String getSumLob() {
return this.sumLob;
}
public void setSumLob(String sumLob) {
this.sumLob = sumLob;
}
public String getSumMrktDist() {
return this.sumMrktDist;
}
public void setSumMrktDist(String sumMrktDist) {
this.sumMrktDist = sumMrktDist;
}
public Timestamp getSumMainframeDate() {
return this.sumMainframeDate;
}
public void setSumMainframeDate(Timestamp sumMainframeDate) {
this.sumMainframeDate = sumMainframeDate;
}
public String getSumUndwrTeam() {
return this.sumUndwrTeam;
}
public void setSumUndwrTeam(String sumUndwrTeam) {
this.sumUndwrTeam = sumUndwrTeam;
}
public String getSumEntryCode() {
return this.sumEntryCode;
}
public void setSumEntryCode(String sumEntryCode) {
this.sumEntryCode = sumEntryCode;
}
public String getSumOriginCde() {
return this.sumOriginCde;
}
public void setSumOriginCde(String sumOriginCde) {
this.sumOriginCde = sumOriginCde;
}
public String getHostKey() {
return this.hostKey;
}
public void setHostKey(String hostKey) {
this.hostKey = hostKey;
}
public Float getAmountAtRisk() {
return this.amountAtRisk;
}
public void setAmountAtRisk(Float amountAtRisk) {
this.amountAtRisk = amountAtRisk;
}
public Float getConversionAmount() {
return this.conversionAmount;
}
public void setConversionAmount(Float conversionAmount) {
this.conversionAmount = conversionAmount;
}
public String getMecindicator() {
return this.mecindicator;
}
public void setMecindicator(String mecindicator) {
this.mecindicator = mecindicator;
}
public String getUnisex() {
return this.unisex;
}
public void setUnisex(String unisex) {
this.unisex = unisex;
}
public String getMarketSegment() {
return this.marketSegment;
}
public void setMarketSegment(String marketSegment) {
this.marketSegment = marketSegment;
}
public String getMarketProgram() {
return this.marketProgram;
}
public void setMarketProgram(String marketProgram) {
this.marketProgram = marketProgram;
}
public String getMktSegmntVerbage() {
return this.mktSegmntVerbage;
}
public void setMktSegmntVerbage(String mktSegmntVerbage) {
this.mktSegmntVerbage = mktSegmntVerbage;
}
public String getPrbFundElection() {
return this.prbFundElection;
}
public void setPrbFundElection(String prbFundElection) {
this.prbFundElection = prbFundElection;
}
public String getDcaFundElection() {
return this.dcaFundElection;
}
public void setDcaFundElection(String dcaFundElection) {
this.dcaFundElection = dcaFundElection;
}
public String getDmdpFundElection() {
return this.dmdpFundElection;
}
public void setDmdpFundElection(String dmdpFundElection) {
this.dmdpFundElection = dmdpFundElection;
}
public String getReinsuranceAccepted() {
return this.reinsuranceAccepted;
}
public void setReinsuranceAccepted(String reinsuranceAccepted) {
this.reinsuranceAccepted = reinsuranceAccepted;
}
public String getEnteredBy() {
return this.enteredBy;
}
public void setEnteredBy(String enteredBy) {
this.enteredBy = enteredBy;
}
public String getApplicationNo() {
return this.applicationNo;
}
public void setApplicationNo(String applicationNo) {
this.applicationNo = applicationNo;
}
public String getApplicationId() {
return this.applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getIllustrationCode() {
return this.illustrationCode;
}
public void setIllustrationCode(String illustrationCode) {
this.illustrationCode = illustrationCode;
}
public String getSumOriginLoc() {
return this.sumOriginLoc;
}
public void setSumOriginLoc(String sumOriginLoc) {
this.sumOriginLoc = sumOriginLoc;
}
public Set getJpNotes() {
return this.jpNotes;
}
public void setJpNotes(Set jpNotes) {
this.jpNotes = jpNotes; }
public void setPolicyNum (com.ifs.app.model.entities.JpSummaryPolComp policyNum) {
this.policyNum = policyNum;
}
public com.ifs.app.model.entities.JpSummaryPolComp getPolicyNum(){
return this.policyNum;
}
}
JpNotes.java
package com.ifs.app.model.entities;
import java.sql.Timestamp;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class JpNotes extends com.ifs.app.model.BaseDomain implements Serializable {
private String recordKey;
private com.ifs.app.model.entities.JpSummaryPolComp jpSummary;
private com.ifs.app.model.entities.JpNotesDesc jpNotesDesc;
private Timestamp noteDate;
private Integer insuredId;
private String userId;
private String note;
/*
private com.ifs.app.model.entities.JpSummary policyNo;
private com.ifs.app.model.entities.JpSummary companyCode;
*/
private String viewExternal;
/** full constructor */
public JpNotes(String recordKey, com.ifs.app.model.entities.JpSummaryPolComp jpSummary, com.ifs.app.model.entities.JpNotesDesc jpNotesDesc, Timestamp noteDate, Integer insuredId, String userId,String note, String viewExternal){
this.recordKey = recordKey;
this.jpSummary = jpSummary;
this.jpNotesDesc = jpNotesDesc;
this.noteDate = noteDate;
this.insuredId = insuredId;
this.userId = userId;
this.note = note;
// this.policyNo = policyNo;
// this.companyCode = companyCode;
this.viewExternal = viewExternal;
}
/** default constructor */
public JpNotes(){
}
/** minimal constructor */
public JpNotes(String recordKey, com.ifs.app.model.entities.JpSummaryPolComp jpSummary, com.ifs.app.model.entities.JpNotesDesc jpNotesDesc, Timestamp noteDate, Integer insuredId, String userId, com.ifs.app.model.entities.JpSummary policyNo){
this.recordKey = recordKey;
this.jpSummary = jpSummary;
this.jpNotesDesc = jpNotesDesc;
this.noteDate = noteDate;
this.insuredId = insuredId;
this.userId = userId;
// this.policyNo = policyNo;
}
public String getRecordKey() {
return this.recordKey;
}
public void setRecordKey(String recordKey) {
this.recordKey = recordKey;
}
public com.ifs.app.model.entities.JpSummaryPolComp getJpSummary() {
return this.jpSummary;
}
public void setJpSummary(com.ifs.app.model.entities.JpSummaryPolComp jpSummary) {
this.jpSummary = jpSummary;
}
public com.ifs.app.model.entities.JpNotesDesc getJpNotesDesc() {
return this.jpNotesDesc;
}
public void setJpNotesDesc(com.ifs.app.model.entities.JpNotesDesc jpNotesDesc) {
this.jpNotesDesc = jpNotesDesc;
}
public Timestamp getNoteDate() {
return this.noteDate;
}
public void setNoteDate(Timestamp noteDate) {
this.noteDate = noteDate;
}
public Integer getInsuredId() {
return this.insuredId;
}
public void setInsuredId(Integer insuredId) {
this.insuredId = insuredId;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
public String getViewExternal() {
return this.viewExternal;
}
public void setViewExternal(String viewExternal) {
this.viewExternal = viewExternal;
}
public String toString() {
return new ToStringBuilder(this)
.append("recordKey",getRecordKey())
.toString();
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( !(other instanceof JpNotes) ) return false;
JpNotes castOther = (JpNotes) other;
return new EqualsBuilder()
.append(this.getRecordKey(), castOther.getRecordKey())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getRecordKey())
.toHashCode();
}
}
In my code see below:
JpSummaryAdaptor jpSummaryAdaptor = this.jpSummaryDAO.findById(
caseNoteRequestDet.getSumCompanyCode(), caseNoteRequestDet
.getSumPolnum());
Set jpNotes = jpSummaryAdaptor.getJpNotes(); Iterator iter = jpNotes.iterator();
when i am trying to get a Set from the jpsummary adaptor its throwing me error.I am attaching the error stack below:I am running through Junit and The bold line error is coming in my console and the below error is coming in the Junit stack trace.
8:31:00,176 in the class org.hibernate.util.JDBCExceptionReporter - Unknown column 'jpnotes0_.SUM_POLNUM' in 'field list'
org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.ifs.app.model.adaptors.JpSummaryAdaptor.jpNotes#component[sumPolnum,sumCompanycode]{sumPolnum=BS20050713A, sumCompanycode=101}]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1923)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1493)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:138)
at com.ifs.app.service.uw.jpcasenote.CaseNoteService.getCaseNote(CaseNoteService.java:98)
at com.ifs.app.service.uw.jpcasenote.CaseNoteService$$FastClassByCGLIB$$2c07e20e.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at com.ifs.app.util.validation.ServiceMethodInterceptor.invoke(ServiceMethodInterceptor.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.ifs.app.service.uw.jpcasenote.CaseNoteService$$EnhancerByCGLIB$$b578c8db.getCaseNote(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy1.getCaseNote(Unknown Source)
at test.com.ifs.app.service.uw.casenote.TestCaseNoteService.testGetCaseNote(TestCaseNoteService.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.SQLException: Unknown column 'jpnotes0_.SUM_POLNUM' in 'field list'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:933)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1676)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
... 48 more
Please help me on this.My problem is when i am trying to get the set its throwing me error.
Thnx in advance
Deba