java代码:
StringBuffer hql = new StringBuffer("SELECT t FROM Citylist t, Employeecityref e WHERE t.citycode = e.citycode and e.employeeid ='"+emp.getEmployeeid()+"'");
List<Citylist> list = getSession().createQuery(hql.toString()).list();出错信息:
org.hibernate.QueryException: could not resolve property: citycode of: com.palmcity.model.Employeecityref [SELECT t FROM com.palmcity.model.Citylist t, com.palmcity.model.Employeecityref e WHERE t.citycode = e.citycode and employeeid ='35']
由于Employeecityref表中没有ID所以映射表有两个Employeecityref.java,EmployeecityrefID.java
请问我的HQL 语句怎么写才能把Citylist调出来
StringBuffer hql = new StringBuffer("SELECT t FROM Citylist t, Employeecityref e WHERE t.citycode = e.citycode and e.employeeid ='"+emp.getEmployeeid()+"'");
List<Citylist> list = getSession().createQuery(hql.toString()).list();出错信息:
org.hibernate.QueryException: could not resolve property: citycode of: com.palmcity.model.Employeecityref [SELECT t FROM com.palmcity.model.Citylist t, com.palmcity.model.Employeecityref e WHERE t.citycode = e.citycode and employeeid ='35']
由于Employeecityref表中没有ID所以映射表有两个Employeecityref.java,EmployeecityrefID.java
请问我的HQL 语句怎么写才能把Citylist调出来
* Employeecityref entity. @author MyEclipse Persistence Tools
*/public class Employeecityref implements java.io.Serializable { // Fields private EmployeecityrefId id; // Constructors /** default constructor */
public Employeecityref() {
} /** full constructor */
public Employeecityref(EmployeecityrefId id) {
this.id = id;
} // Property accessors public EmployeecityrefId getId() {
return this.id;
} public void setId(EmployeecityrefId id) {
this.id = id;
}}
package com.palmcity.model;import java.math.BigDecimal;/**
* EmployeecityrefId entity. @author MyEclipse Persistence Tools
*/public class EmployeecityrefId implements java.io.Serializable { // Fields private Long employeeid;
private String citycode; // Constructors /** default constructor */
public EmployeecityrefId() {
} /** full constructor */
public EmployeecityrefId(Long employeeid, String citycode) {
this.employeeid = employeeid;
this.citycode = citycode;
} // Property accessors public Long getEmployeeid() {
return this.employeeid;
} public void setEmployeeid(Long employeeid) {
this.employeeid = employeeid;
} public String getCitycode() {
return this.citycode;
} public void setCitycode(String citycode) {
this.citycode = citycode;
} public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof EmployeecityrefId))
return false;
EmployeecityrefId castOther = (EmployeecityrefId) other; return ((this.getEmployeeid() == castOther.getEmployeeid()) || (this
.getEmployeeid() != null
&& castOther.getEmployeeid() != null && this.getEmployeeid()
.equals(castOther.getEmployeeid())))
&& ((this.getCitycode() == castOther.getCitycode()) || (this
.getCitycode() != null
&& castOther.getCitycode() != null && this
.getCitycode().equals(castOther.getCitycode())));
} public int hashCode() {
int result = 17; result = 37
* result
+ (getEmployeeid() == null ? 0 : this.getEmployeeid()
.hashCode());
result = 37 * result
+ (getCitycode() == null ? 0 : this.getCitycode().hashCode());
return result;
}}
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.palmcity.model.Employeecityref" table="EMPLOYEECITYREF" schema="TRAFFICS">
<composite-id name="id" class="com.palmcity.model.EmployeecityrefId">
<key-property name="employeeid" type="java.lang.Long">
<column name="EMPLOYEEID" precision="22" scale="0" />
</key-property>
<key-property name="citycode" type="java.lang.String">
<column name="CITYCODE" length="20" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>这是类映射文件
是这样的:From a where a.id.citycode='11'