我有一個員工表,其中包含empId,empName,Dept,DOJ,DoB,Sex,Qualification和我的數據庫中的大量記錄。如何僅通過Hibernate和使用JAXB編組從數據庫中提取幾個表列?
我的服務和DAO類和我的EMP Java資源類如下:
@Entity
@Table(name="EMP")
@XmlRootElement(name = "EmpResource")
public class Employee{
private String empId;
private String empName;
private String href; // this field doesn't exist in the database table.
@XmlElement
public String getEmpId(){
return empId;
}
@XmlElement
public String getEmpName(){
return empId;
}
@XmlAttribute
public String getHref(){
return "http://host/rest/v1/employees/" + empId;
}
}
我正在創建一個基於REST的網址,其中網址http://host/rest/v1/employees以獲取所有記錄只EMPID, EmpName和HREF領域,但是當我嘗試運行應用程序,我得到這個錯誤
javax.xml.bind.JAXBException: class com.vargo.EmpResource nor any of its super class is known to this context.
任何幫助?
問候, Kicha
以下示例可能有所幫助:http://blog.bdoughan.com/2010/08/creating-restful-web-service-part-45.html – 2012-04-09 16:00:51