JPA Could not serialize

I have this class, but when I make a query it throws an exception:

org.hibernate.type.SerializationException: could not serialize

public class Google implements Serializable{

String nombre;
String pass;

public Google() {
    nombre = "defecto";
    pass = "defecto";

public Google(String anom, String apass) {
    nombre = anom;
    pass = apass;
//Getters, setters..


This is the query, I am using JPA, hibernate and a MySQL DB, and the class implements Serializable I don’t know which is the problem.

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();


In the following line :

query.setParameter(1, nombresAmigos);

nombresAmigos should be a List<String>, not a Map<String, Amigo>.

Leave a Reply

Your email address will not be published. Required fields are marked *