Erro ao salvar ArrayList

3 respostas
douglascst90
Galera td bom? Estou com problemas, preciso salvar um ArrayList<>, no meu banco, esta dando erro, peço a ajuda de voces para darem uma olhada e ver se tem algo de errado no meu codigo, mas fiz o debug e ele gera erro quando tento abrir a session no(HibernateUtil), olhem meu codigo:
public void enviar(ArrayList<Cliente> listaClientes) throws Exception {

       
        try {
    
            session = HibernateUtil.getSessionFactory().openSession(); // o erro acontece nessa linha
            transaction = session.beginTransaction();
            session.saveOrUpdate(listaClientes);
            transaction.commit();

            if (sucesso > 0) {
                System.out.println("CLIENTE INSERIDO!!!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            transaction.rollback();
            throw new Exception("Erro ao salvar!");
        } finally {
            session.close();
        }
    }
}

Só para confirmar se o meu erro esta quando tento abrir a session, ou se esta no codigo.

Qualquer ajuda sera util, obrigado!

3 Respostas

Milton_Quirino

bom dia douglascst90 ,

Cole a exception que esta gerando aqui

douglascst90
Informações: configuring from resource: /hibernate.cfg.xml
Informações: Configuration resource: /hibernate.cfg.xml
Informações: Configured SessionFactory: null
Informações: Binding entity from annotated class: br.com.droid.model.Cliente
Informações: Bind entity br.com.droid.model.Cliente on table tb_contribuinte
Informações: Hibernate Validator not found: ignoring
Informações: Using Hibernate built-in connection pool (not for production use!)
Informações: Hibernate connection pool size: 20
Informações: autocommit mode: false
Informações: using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/droidmap
Informações: connection properties: {user=postgres, password=****}
Informações: RDBMS: PostgreSQL, version: 9.1.2
Informações: JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 603)
Informações: Using dialect: org.hibernate.dialect.PostgreSQLDialect
Informações: Using default transaction strategy (direct JDBC transactions)
Informações: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Informações: Automatic flush during beforeCompletion(): disabled
Informações: Automatic session close at end of transaction: disabled
Informações: JDBC batch size: 15
Informações: JDBC batch updates for versioned data: disabled
Informações: Scrollable result sets: enabled
Informações: JDBC3 getGeneratedKeys(): disabled
Informações: Connection release mode: auto
Informações: Default batch fetch size: 1
Informações: Generate SQL with comments: disabled
Informações: Order SQL updates by primary key: disabled
Informações: Order SQL inserts for batching: disabled
Informações: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Informações: Using ASTQueryTranslatorFactory
Informações: Query language substitutions: {}
Informações: JPA-QL strict compliance: disabled
Informações: Second-level cache: enabled
Informações: Query cache: disabled
Informações: Cache provider: org.hibernate.cache.NoCacheProvider
Informações: Optimize cache for minimal puts: disabled
Informações: Structured second-level cache entries: disabled
Informações: Echoing all SQL to stdout
Informações: Statistics: disabled
Informações: Deleted entity synthetic identifier rollback: disabled
Informações: Default entity-mode: pojo
Informações: Named query checking : enabled
Informações: building session factory
Grave:  ... Initial SessionFactory creation failed: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
Informações: Erro...

Esse erro:

Grave: ... Initial SessionFactory creation failed: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V ele gera no HibernateUtil quando ele tenta abrir a session e nao consegue…

douglascst90

alguém galera???

Criado 9 de março de 2012
Ultima resposta 9 de mar. de 2012
Respostas 3
Participantes 2