I have 2 questions: suppose we have one entity named class and another called student. each class has onetomany students.
public class Clas implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
private int id;
@OneToMany(cascade=CascadeType.ALL)
Collection<Student> students;
public clas(){
super();
}
..... getters and setters
}
q1: i get the exception there are no fields to be mapped, when adding any other column like String name, it works, but i don't need that field what can i do ?
q2: the ids is autogenerated, and i want to query all students in class c1, but i don't has the id of this class, how to do such query ?
iam working with mysql server glassfish v2.1 toplink jpa 1.0
Thanks
ok. I think I understood you question. You may use NamedQueries written in Query Languages dependent on your library (in your case toplink) like EJB QL or HBQL. You can create Session Beans for querying.
Note that the above code may contain syntax errors because I have not checked it anywhere.
Hope you find some help from this :) .