JPA外键查询报错:could not resolve property

hwlsniper 发布于 2014/09/18 15:55
阅读 954
收藏 0
以下有两个实体类:
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;

@Entity(name="record")
public class Record extends BaseObject {

	private String name;			//姓名
	
	private String sex;				//性别
	
	private Date birthday;			//出生年月
	
	private String family;			//民族
	
	private String marital_status;	//婚姻状况
	
	private String politics_status; //政治面貌  
	
	private String id_number;		//身份证号
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)//级联保存、更新、删除、刷新;延迟加载  
	@JoinColumn(name="record_id")//在eduexp表增加一个外键列来实现一对多的单向关联
	private Set<Eduexp> eduexp = new HashSet<Eduexp>();			//教育培训经历

省略 getter 和 setter 方法
}

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Entity(name="eduexp")
public class Eduexp extends BaseObject {

	private Date edu_time;	//起始时间
	private Date edu_endtime;//结束时间
	private String edu_org;	//教育培训机构
	private String course;	//专业或课程
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, optional = false) 
    	private Record record;
	
	省略 getter 和 setter 方法
}

我想通过 eduexp 中的外键 record_id 查询 eduexp  中的数据,该怎么做?

以下是我的查询方法:

public String queryReocrdData(){

StringBuffer str_hql = new StringBuffer();
str_hql.append("SELECT new com.ewayit.model.Eduexp(E.edu_time, E.edu_endtime, E.edu_org, E.course) FROM ")
  .append("com.ewayit.model.Eduexp E WHERE E.RECORD_ID = ?1");

try {
toJson(getService().find(str_hql.toString(), id));


} catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException | IntrospectionException e) {


e.printStackTrace();
}

return Action.SUCCESS;
}

但是调用这个方法查询的时候报错:

求大神帮忙!!

加载中
返回顶部
顶部