I need to use hibernate to retrive data from a table with no primary keys.the table has a combination of 4 columns which together make up the pry key.I'm using the hibernate composite-id mapping but i'm having difficulty loading the object in hibernate.I don't know wot i'm doing wrong.Pls i need help urgently. I've included the class,there is the class which implements serializable and then the hbm file. and also where i'm trying to load it in hibernate.
The class:
package com.gtbank.swiftnetworksModel;
import java.util.Date;
/**
*
* @author Teeman
*/
public class Tell_act {
private String id;
private Tell_act_PK Tell_act_PK;
private int cusNum ;
private int curCode;
private int ledCode;
private int subAcctCode;
private int tellId;
private int extIntFlag ;
private int depCode;
private int disCode;
private int traAmt;
private int debCreInd;
private int manApp;
private int manRep;
private int explCode;
private Date valDate;
private Date intDate;
private int canReaCode;
private int docAlp;
private int docNum;
private int curPri;
private long equTraAmt;
private int origtBraCode;
private Date origtTraDate;
private int origtTraSeq1;
private int origtTraSeq2;
private int draOnBraCode;
private int bankCode;
private int cityLocCode;
private int bloSeq;
private int debInt;
private int penInt;
private int creInt;
private String remarks;
private int proCode;
private int updTime;
/** Creates a new instance of Tell_act */
public Tell_act() {
}
public String getId(){
return id;
}
public void setId(String id){
this.id = id;
}
public Tell_act_PK getTell_act_PK(){
return Tell_act_PK;
}
public void setTell_act_PK(Tell_act_PK Tell_act_PK){
this.Tell_act_PK = Tell_act_PK;
}
public int getCusNum(){
return cusNum;
}
public void setCusNum(int cusNum){
this.cusNum = cusNum;
}
public int getCurCode(){
return curCode;
}
public void setCurCode(int curCode){
this.curCode = curCode;
}
public int getLedCode(){
return ledCode;
}
public void setLedCode(int ledCode){
this.ledCode = ledCode;
}
public int getSubAcctCode(){
return subAcctCode;
}
public void setSubAcctCode(int subAcctCode){
this.subAcctCode = subAcctCode;
}
public int getTellId(){
return tellId;
}
public void setTellId(int tellId){
this.tellId = tellId;
}
public int getExtIntFlag(){
return extIntFlag;
}
public void setExtIntFlag(int extIntFlag){
this.extIntFlag = extIntFlag;
}
public int getDepCode(){
return depCode;
}
public void setDepCode(int depCode){
this.depCode = depCode;
}
public int getDisCode(){
return disCode;
}
public void setDisCode(int disCode){
this.disCode = disCode;
}
public int getTraAmt(){
return traAmt;
}
public void setTraAmt(int traAmt){
this.traAmt = traAmt;
}
public int getDebCreInd(){
return debCreInd;
}
public void setDebCreInd(int debCreInd){
this.debCreInd = debCreInd;
}
public int getManApp(){
return manApp;
}
public void setManApp(int manApp){
this.manApp = manApp;
}
public int getManRep(){
return manRep;
}
public void setManRep(int manRep){
this.manRep = manRep;
}
public int getExplCode(){
return explCode;
}
public void setExplCode(int explCode){
this.explCode = explCode;
}
public Date getValDate(){
return valDate;
}
public void setValDate(Date valDate){
this.valDate = valDate;
}
public Date getIntDate(){
return intDate;
}
public void setIntDate(Date intDate){
this.intDate = intDate;
}
public int getCanReaCode(){
return canReaCode;
}
public void setCanReaCode(int canReaCode){
this.canReaCode = canReaCode;
}
public int getDocAlp(){
return docAlp;
}
public void setDocAlp(int docAlp){
this.docAlp = docAlp;
}
public int getDocNum(){
return docNum;
}
public void setDocNum(int docNum){
this.docNum = docNum;
}
public int getCurPri(){
return curPri;
}
public void setCurPri(int curPri){
this.curPri = curPri;
}
public long getEquTraAmt(){
return equTraAmt;
}
public void setEquTraAmt(long equTraAmt){
this.equTraAmt = equTraAmt;
}
public int getOrigtBraCode(){
return origtBraCode;
}
public void setOrigtBraCode(int origtBraCode){
this.origtBraCode = origtBraCode;
}
public Date getOrigtTraDate(){
return origtTraDate;
}
public void setOrigtTraDate(Date origtTraDate){
this.origtTraDate = origtTraDate;
}
public int getOrigtTraSeq1(){
return origtTraSeq1;
}
public void setOrigtTraSeq1(int origtTraSeq1){
this.origtTraSeq1 = origtTraSeq1;
}
public int getOrigtTraSeq2(){
return origtTraSeq2;
}
public void setOrigtTraSeq2(int origtTraSeq2){
this.origtTraSeq2 = origtTraSeq2;
}
public int getDraOnBraCode(){
return draOnBraCode;
}
public void setDraOnBraCode(int draOnBraCode){
this.draOnBraCode = draOnBraCode;
}
public int getBankCode(){
return bankCode;
}
public void setBankCode(int bankCode){
this.bankCode = bankCode;
}
public int getCityLocCode(){
return cityLocCode;
}
public void setCityLocCode(int cityLocCode){
this.cityLocCode = cityLocCode;
}
public int getBloSeq(){
return bloSeq;
}
public void setBloSeq(int bloSeq){
this.bloSeq = bloSeq;
}
public int getDebInt(){
return debInt;
}
public void setDebInt(int debInt){
this.debInt = debInt;
}
public int getPenInt(){
return penInt;
}
public void setPenInt(int penInt){
this.penInt = penInt;
}
public int getCreInt(){
return creInt;
}
public void setCreInt(int creInt){
this.creInt = creInt;
}
public String getRemarks(){
return remarks;
}
public void setRemarks(String remarks){
this.remarks = remarks;
}
public int getProCode(){
return proCode;
}
public void setProCode(int proCode){
this.proCode = proCode;
}
public int getUpdTime(){
return updTime;
}
public void setUpdTime(int updTime){
this.updTime = updTime;
}
}
************************************************
The one that implements sirializable
package com.gtbank.swiftnetworksModel;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Administrator
*/
public class Tell_act_PK implements Serializable {
private Date traDate ;
private int traSeq1;
private int traSeq2;
private int braCode;
/** Creates a new instance of Tell_act_PK */
public Tell_act_PK() {
}
public Date getTraDate(){
return traDate;
}
public void setTraDate(Date traDate){
this.traDate = traDate;
}
public int getTraSeq1(){
return traSeq1;
}
public void setTraSeq1(int traSeq1){
this.traSeq1 = traSeq1;
}
public int getTraSeq2(){
return traSeq2;
}
public void setTraSeq2(int traSeq2){
this.traSeq2 = traSeq2;
}
public int getBraCode(){
return braCode;
}
public void setBraCode(int braCode){
this.braCode = braCode;
}
}
*************************************************
The hbm file
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.gtbank.swiftnetworksModel">
<class name="Tell_act" table="Tell_act">
<!-- Tell_act_PK is another class that implements Serializable -->
<composite-id name="Tell_act_PK" class="Tell_act_PK" >
<key-property name="traDate" column="TRA_DATE" type="timestamp" />
<key-property name="traSeq1" column="TRA_SEQ1" type="integer"/>
<key-property name="traSeq2" column="TRA_SEQ2" type="integer"/>
<key-property name="braCode" column="BRA_CODE" type="integer"/>
</composite-id>
<property column="CUS_NUM" name="cusNum"/>
<property column="CUR_CODE" name="curCode"/>
<property column="LED_CODE" name="ledCode"/>
<property column="SUB_ACCT_CODE" name="subAcctCode"/>
<property column="TELL_ID" name="tellId"/>
<property column="EXT_INT_FLAG" name="extIntFlag"/>
<property column="DEP_CODE" name="depCode"/>
<property column="DIS_CODE" name="disCode"/>
<property column="TRA_AMT" name="traAmt"/>
<property column="DEB_CRE_IND" name="debCreInd"/>
<property column="MAN_APP" name="manApp"/>
<property column="MAN_REP" name="manRep"/>
<property column="EXPL_CODE" name="explCode"/>
<property column="VAL_DATE" name="valDate" type="timestamp"/>
<property column="INT_DATE" name="intDate" type="timestamp"/>
<property column="CAN_REA_CODE" name="canReaCode"/>
<property column="DOC_ALP" name="docAlp"/>
<property column="DOC_NUM" name="docNum"/>
<property column="CUR_PRI" name="curPri"/>
<property column="EQU_TRA_AMT" name="equTraAmt"/>
<property column="ORIGT_BRA_CODE" name="origtBraCode"/>
<property column="ORIGT_TRA_DATE" name="origtTraDate" type="timestamp"/>
<property column="ORIGT_TRA_SEQ1" name="origtTraSeq1"/>
<property column="ORIGT_TRA_SEQ2" name="origtTraSeq2"/>
<property column="DRA_ON_BRA_CODE" name="draOnBraCode"/>
<property column="BANK_CODE" name="bankCode"/>
<property column="CITY_LOC_CODE" name="cityLocCode"/>
<property column="BLO_SEQ" name="bloSeq"/>
<property column="DEB_INT" name="debInt"/>
<property column="PEN_INT" name="penInt"/>
<property column="CRE_INT" name="creInt"/>
<property column="REMARKS" name="remarks"/>
<property column="PRO_CODE" name="proCode"/>
<property column="UPD_TIME" name="updTime"/>
</class>
</hibernate-mapping>
*********************************************
The class wich loads hibernate
private void ObtainTellerAction(HttpServletRequest request , HttpServletResponse response){
try{
Tell_act tellerAction = new Tell_act();
tellerAction = (Tell_act)hibernateUtil.loadObject(tellerAction,cusNum);
request.setAttribute("tellerAction",tellerAction);
}catch(Exception e){
ExceptionManager exmgr = new ExceptionManager();
exmgr.processException(e, "Error in obtainTellerAction() for MailServiceCommand");
}
}
public Object loadObject( Object object, String id) throws Exception{
Object result = null;
List objectList = loadObjectsFromQuery("select o from " + object.getClass().getName() + " as o where o.id = ?", id);
Iterator it = objectList.iterator();
return (Object)it.next();
}
error msg: Null-Pointer exception
|