I have one table
Objtablee
Annotations
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
Code:
package test;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
*
* @author baktha
*/
@Entity
@Table(name = "objtablee")
@NamedQueries({@NamedQuery(name = "Objtablee.findAll", query = "SELECT o FROM Objtablee o"), @NamedQuery(name = "Objtablee.findById", query = "SELECT o FROM Objtablee o WHERE o.id = :id"), @NamedQuery(name = "Objtablee.findByLongi", query = "SELECT o FROM Objtablee o WHERE o.longi = :longi"), @NamedQuery(name = "Objtablee.findByLat", query = "SELECT o FROM Objtablee o WHERE o.lat = :lat"), @NamedQuery(name = "Objtablee.findByAltitude", query = "SELECT o FROM Objtablee o WHERE o.altitude = :altitude"), @NamedQuery(name = "Objtablee.findByAngle", query = "SELECT o FROM Objtablee o WHERE o.angle = :angle"), @NamedQuery(name = "Objtablee.findBySatellite", query = "SELECT o FROM Objtablee o WHERE o.satellite = :satellite"), @NamedQuery(name = "Objtablee.findBySpeed", query = "SELECT o FROM Objtablee o WHERE o.speed = :speed"), @NamedQuery(name = "Objtablee.findByObjectId", query = "SELECT o FROM Objtablee o WHERE o.objectId = :objectId"), @NamedQuery(name = "Objtablee.findByClientId", query = "SELECT o FROM Objtablee o WHERE o.clientId = :clientId"), @NamedQuery(name = "Objtablee.findByGpsTime", query = "SELECT o FROM Objtablee o WHERE o.gpsTime = :gpsTime"), @NamedQuery(name = "Objtablee.findByLocation", query = "SELECT o FROM Objtablee o WHERE o.location = :location"), @NamedQuery(name = "Objtablee.findByCity", query = "SELECT o FROM Objtablee o WHERE o.city = :city"), @NamedQuery(name = "Objtablee.findByState", query = "SELECT o FROM Objtablee o WHERE o.state = :state"), @NamedQuery(name = "Objtablee.findByDistance", query = "SELECT o FROM Objtablee o WHERE o.distance = :distance"), @NamedQuery(name = "Objtablee.findByTimes", query = "SELECT o FROM Objtablee o WHERE o.times = :times")})
public class Objtablee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Column(name = "Longi")
private String longi;
@Column(name = "Lat")
private String lat;
@Basic(optional = false)
@Column(name = "Altitude")
private int altitude;
@Basic(optional = false)
@Column(name = "Angle")
private int angle;
@Basic(optional = false)
@Column(name = "Satellite")
private int satellite;
@Basic(optional = false)
@Column(name = "Speed")
private int speed;
@Basic(optional = false)
@Column(name = "ObjectId")
private long objectId;
@Basic(optional = false)
@Column(name = "ClientId")
private int clientId;
@Basic(optional = false)
@Column(name = "GpsTime")
@Temporal(TemporalType.TIMESTAMP)
private String gpsTime;
@Column(name = "Location")
private String location;
@Column(name = "City")
private String city;
@Column(name = "State")
private String state;
@Column(name = "Distance")
private String distance;
@Basic(optional = false)
@Column(name = "Times")
@Temporal(TemporalType.TIMESTAMP)
private Date times;
@JoinColumn(name = "ID", referencedColumnName = "ID", insertable = false, updatable = false)
@OneToOne(optional = false)
private Xydataa xydataa;
public Objtablee() {
}
public Objtablee(Integer id) {
this.id = id;
}
public Objtablee(Integer id, int altitude, int angle, int satellite, int speed, long objectId, int clientId, String gpsTime, Date times) {
this.id = id;
this.altitude = altitude;
this.angle = angle;
this.satellite = satellite;
this.speed = speed;
this.objectId = objectId;
this.clientId = clientId;
this.gpsTime = gpsTime;
this.times = times;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getLongi() {
return longi;
}
public void setLongi(String longi) {
this.longi = longi;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getAngle() {
return angle;
}
public void setAngle(int angle) {
this.angle = angle;
}
public int getSatellite() {
return satellite;
}
public void setSatellite(int satellite) {
this.satellite = satellite;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public long getObjectId() {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public int getClientId() {
return clientId;
}
public void setClientId(int clientId) {
this.clientId = clientId;
}
public String getGpsTime() {
return gpsTime;
}
public void setGpsTime(String gpsTime) {
this.gpsTime = gpsTime;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getDistance() {
return distance;
}
public void setDistance(String distance) {
this.distance = distance;
}
public Date getTimes() {
return times;
}
public void setTimes(Date times) {
this.times = times;
}
public Xydataa getXydataa() {
return xydataa;
}
public void setXydataa(Xydataa xydataa) {
this.xydataa = xydataa;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Objtablee)) {
return false;
}
Objtablee other = (Objtablee) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "test.Objtablee[id=" + id + "]";
}
}
Main file
Code:
sess = HibernateUtil.getSessionFactory().openSession();
tr1 = sess.beginTransaction();
Date resultdate = new Date(tims);
xx = new DecimalNumber(x,7);
yy = new DecimalNumber(y,7);
Iterator conList1 = sess.createQuery("from Objtablee as ob where ob.ObjectId ='"+ObjectId+"' and ob.ClientId='"+ClientId+"'").list().iterator();
while(conList1.hasNext()){
Objtablee o = (Objtablee)conList1.next();
GpsTime1 = o.getGpsTime();
I got this error
org.hibernate.QueryException: could not resolve property: ObjectId of: test.Objtablee [from test.Objtablee as ob where ob.ObjectId ='18' and ob.ClientId='1']
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1358)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:566)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:241)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:188)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
What i am doing wrong please help me