Bom dia galera…Estou com um problema aqui quando vou persistir alguns dados…
Eu tenho uma lista de unidades que eu posso relacionar há um objeto porém quando eu persisto mais de 1 objeto ele está me dizendo que não pode sincronizar o estado do banco com a sessão.
o código é o seguinte.
List grupamUnidades = GrupamentoTOBuilder.buildGrupamentoUnidade(
userId, idGrupam, unidades);
if (grupamUnidades != null) {
try {
for (Iterator iter = grupamUnidades.iterator(); iter.hasNext();) {
Grupamentounidade grupamUnid = Grupamentounidade) iter.next();
this.persist(grupamUnid);
}
} catch (Exception ex) {
throw DAOExceptionBuilder.build(ex);
}
Quando eu tenho mais de 1 objeto na lista e ele passa pela segunda vez no persist ele cai no catch e exibe o seguinte erro no log…
11:13:47,502 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000
11:13:47,502 ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00001: unique constraint (ACESSO.GRUPAMENTOUNIDADEAK1) violated
11:13:47,502 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000
11:13:47,502 ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00001: unique constraint (ACESSO.GRUPAMENTOUNIDADEAK1) violated
11:13:47,518 ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
Vlws ae galera!!!