here is my code snippet:
@Stateless public class mySLSB { @PersistenceContext(unitName = "db") private EntityManager myEntityManager; public void crud(MyEntity myEntity) throws MyException { myEntityManager.merge(myEntity); } }
However, this merge can throw a ConstraintViolationException that does not throw a MyException (which gets into the calling servlet).
What is the best way to catch exceptions for sleep mode?
However, this merge can throw a ConstraintViolationException that does not throw a MyException (which gets into the calling servlet). What is the best way to catch sleep mode exceptions?
JPA API EntityManager javax.persistence.RollbackException ConstraintViolationException . , RollbackException getCause(), .
javax.persistence.RollbackException
ConstraintViolationException
RollbackException
getCause()
- . . , ConstraintViolationException, , . , , . , , - , / .
catch HibernateException . ( , / , ).
HibernateException
, ConstraintViolationException. , , getConstraintName() ConstraintViolationException. .
getConstraintName()
Source: https://habr.com/ru/post/1772157/More articles:How to define a separator in a string in PHP? - stringAn efficient way to randomize an array - Random code - performanceIs there a “single line” method for generating an encrypted line? - securityWCF SOAP service that changes the name of elements in an array element during (de) serialization - c #Named searches in Vim? - vimКак установить несколько пакетов и постобработку? - installerhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1772159/how-can-i-get-auto-completion-in-bash-for-file-names-with-spaces-too&usg=ALkJrhiWjeSn9LsqY2qetpsFxsbETtrzYAиспользуя float ('nan') для представления отсутствующих значений - безопасно? - pythonCall VB CreateObject method in C ++ - c ++получение ActiveRecord:: RecordNotSaved при сохранении - rubyAll Articles