【发布时间】:2014-11-03 20:44:27
【问题描述】:
我有这个类,但是当我进行查询时会抛出异常:
org.hibernate.type.SerializationException: 无法序列化
@Entity
public class Google implements Serializable{
@Id
String nombre;
String pass;
public Google() {
nombre = "defecto";
pass = "defecto";
}
public Google(String anom, String apass) {
nombre = anom;
pass = apass;
}
//Getters, setters..
}
这是查询,我正在使用 JPA、hibernate 和 MySQL DB,并且该类实现了 Serializable 我不知道是哪个问题。
public void findNombresGoogle(Map<String, Amigo> anombresAmigos){
List<Google> resultados = new LinkedList<Google>();
Map<String, Amigo> nombresAmigos = anombresAmigos;
Query query = entityManager.createNativeQuery("FROM Google google WHERE "
+ "google.nombre IN (?1)", Google.class);
query.setParameter(1, nombresAmigos);
resultados = (List<Google>) query.getResultList();
}
【问题讨论】:
标签: java mysql hibernate jpa serialization