ok this is my Entity class again
Code:
package com.aura.data.trn;
import com.aura.util.HibernateUtil;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.annotations.GenericGenerator;
//To represent TRN_HGT_QUATA
@Entity
@Table(name="TRN_HGT_QUATA")
public class HighGrownTea implements Serializable {
private int id;
private int saleNumber;
private String saleYear;
private String quotation;
private String bop;
private String bopf;
private String pekoeFbop;
private String op;
public HighGrownTea() {
}
public HighGrownTea(int saleNumber, String saleYear) {
this.saleNumber = saleNumber;
this.saleYear = saleYear;
}
public ArrayList getHGTObj(HighGrownTea hgt){
Transaction transaction = null;
ArrayList<HighGrownTea> hgts = null;
Session session = null;
try{
session = HibernateUtil.getInstance().getCurrentSession();
transaction = session.beginTransaction();
hgts = (ArrayList<HighGrownTea>)session.createQuery("FROM HighGrownTea hgt WHERE hgt.saleNumber=:sales_no AND hgt.saleYear=:sales_year").setInteger("sales_no", hgt.getSaleNumber()).setString("sales_year", hgt.getSaleYear()).list();
transaction.commit();
System.out.println(hgts.size());
//return hgts;
}
catch(Exception ex){
System.out.println("*******************"+ex.toString()+"*******************");
}
return hgts;
}
@Column(name="BOP")
public String getBop() {
return bop;
}
public void setBop(String bop) {
this.bop = bop;
}
@Column(name="BOPF")
public String getBopf() {
return bopf;
}
public void setBopf(String bopf) {
this.bopf = bopf;
}
@Id
@GenericGenerator(name="generator", strategy="increment")
@GeneratedValue(generator="generator")
@Column(name="ID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="OP")
public String getOp() {
return op;
}
public void setOp(String op) {
this.op = op;
}
@Column(name="PEKOE/FBOP")
public String getPekoeFbop() {
return pekoeFbop;
}
public void setPekoeFbop(String pekoeFbop) {
this.pekoeFbop = pekoeFbop;
}
@Column(name="QUATATIONS IN (RS/KGS)")
public String getQuotation() {
return quotation;
}
public void setQuotation(String quotation) {
this.quotation = quotation;
}
@Id
@Column(name="SALES_NO")
public int getSaleNumber() {
return saleNumber;
}
public void setSaleNumber(int saleNumber) {
this.saleNumber = saleNumber;
}
@Id
@Column(name="SALES_YEAR")
public String getSaleYear() {
return saleYear;
}
public void setSaleYear(String saleYear) {
this.saleYear = saleYear;
}
}
This is the code which call this entity class's method
Code:
<%@ page import="com.aura.data.model.*" %>
<%@ page import="com.aura.data.trn.*" %>
<%@ page import="java.util.*" %>
<%
//If the userAction is 'view' then this form should be filled
String userAction = null;
String saleNumber = null;
String saleYear = null;
try{
userAction = session.getAttribute("userAction").toString();
saleNumber = session.getAttribute("sale_number").toString();
saleYear = session.getAttribute("sale_year").toString();
System.out.println(userAction);
if(userAction.equals("view")){
}
}
catch(IllegalStateException ise){
}
//HighGrownTea highGrownTea = new HighGrownTea();
HighGrownTea highGrownTea = new HighGrownTea(Integer.parseInt(saleNumber), saleYear);
ArrayList hgtList = highGrownTea.getHGTObj(highGrownTea);
System.out.println(hgtList.size());
%>
I cannot find stackTrace....
this is the error
================
org.hibernate.QueryException: could not resolve property: saleNumber of: com.aura.data.trn.HighGrownTea [FROM com.aura.data.trn.HighGrownTea hgt WHERE hgt.saleNumber=:sales_no AND hgt.saleYear=:sales_year]
================
regards,
Dilan.