ich in meinem application gesetzt habenDataAccessException funktioniert nicht
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
und ich versuche, die DataAccessException in ManagedBean zu fangen. Ich habe BusinessDelegate, wo ich @Transactional eingestellt habe.
Das Problem ist:
try
{
operazioneOk = businessDelegate.insertAuto(newAuto);
}
catch (DataAccessException e)
{
System.out.println("autoBean");
}
der Fang, Arbeit, selbst wenn ich nicht setzen
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
aber das Merkwürdige ist, dass in der Konsole Ich habe diese Ausnahme:
AVVERTENZA: SQL Error: 0, SQLState: null
GRAVE: L'operazione «batch» 0 insert into public.auto (marca, modello, anno, km, cilindrata, optional, prezzo, occasione, id) values (w, ww, w, w, w, w, w, 0, 12) è stata interrotta. Chiamare «getNextException» per scoprirne il motivo.
AVVERTENZA: SQL Error: 0, SQLState: 23505
GRAVE: ERROR: duplicate key value violates unique constraint "auto_marca_key"
Dettaglio: Key (marca)=(w) already exists.
GRAVE: Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
In beiden Fällen. Ich denke, dass etwas nicht funktioniert. Hilf mir!
Ich weiß, dass: Duplikatschlüssel ist mein Problem, aber wenn ich Ausnahme erfahre, sehe ich immer den Stack-Trace und mindestens System.out.println ("autoBean"); –