Hi all,
I have query regarding usage of @Loader attribute. I just don't understand how to use it. I tried all possible ways to make it work, but no success. Can anybody Please have look at this code and let me know what is wrong.
I am using Seam Framework 2.1.1 for creating my application.
Code:
@Entity
@Table(name = "employee")
@NamedNativeQuery(name="employee", query="Select * from employee where roleId > 3", resultClass = Employee.class)
@Loader(namedQuery="employee")
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "empId")
private int id;
@Column(name = "empName")
private String name;
@Column(name = "salary")
private int salary;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "deptId")
private Department dept;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "emp_proj", joinColumns = @JoinColumn(name = "empId"), inverseJoinColumns = @JoinColumn(name = "id"))
private List<EmpProject> emp_proj;
@Column(name = "roleId")
@Enumerated(EnumType.ORDINAL)
private Role role;
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public Department getDept() {
return dept;
}
public void setDept(Department dept) {
this.dept = dept;
}
public List<EmpProject> getEmp_proj() {
return emp_proj;
}
public void setEmp_proj(List<EmpProject> emp_proj) {
this.emp_proj = emp_proj;
}
}
And I am getting list of Employee as
entityManager.createQuery("from Employee");
Is here anything wrong?
[/color]
Please help me. :)