我有以下实体
@Entity
public class Employee{
private Integer id;
private String name;
private String address;
private Date created;
@OneToMany(mappedBy = "employee")
private Set<Language> languages = new HashSet<AlbumUser>()
}
和语言实体是
@Entity
public class Language{
private String name;
@ManyToOne
@JoinColumn(name = "employee_id")
private Employee employee;
}
我的语言表如下所示
我想选择所有姓名以 A 开头并且知道 java 和 C 的员工,为此我正在尝试关注
DetachedCriteria criteria = DetachedCriteria.forClass(Employee.class,"employee");
criteria.add( Restrictions.ilike("name", "A%") );
criteria.add(Restrictions.in("languages",languageSet));
return getHibernateTemplate().findByCriteria(criteria)
语言集在哪里
Set<Language> languageSet = new HashSet();
languageSet.add(new Language("Java"));
languageSet.add(new Language("C"));
我可以看到我的尝试是完全错误的......我是新来的休眠有人可以帮我解决它..
Caused by: java.sql.SQLException: No value specified for parameter 2
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2176)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2100