Hi, We've just noticed that as result of the recent error code changes, Spring JdbcTemplate doesn't detect duplicate key condition with H2 1.3.154, DataIntegrityViolationException is thrown instead of DuplicateKeyException.
I've submitted an issue for Spring regarding this: https://jira.springsource.org/browse/SPR-8235 If someone else also uses Spring JdbcTemplate and rely on DuplicateKeyException to be thrown, it's easy to work this around by customizing SQL error code mapping - just put the following XML file into the root of classpath: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > <import resource="classpath:org/springframework/jdbc/support/sql- error-codes.xml"/> <bean id="H2" class="org.springframework.jdbc.support.SQLErrorCodes"> <property name="badSqlGrammarCodes"> <value>42000,42001,42101,42102,42111,42112,42121,42122,42132</ value> </property> <property name="duplicateKeyCodes"> <value>23001,23505</value> </property> <property name="dataIntegrityViolationCodes"> <value>22003,22012,22025,23000</value> </property> <property name="dataAccessResourceFailureCodes"> <value>90046,90100,90117,90121,90126</value> </property> <property name="cannotAcquireLockCodes"> <value>50200</value> </property> </bean> </beans> It adds 23505 code to duplicateKeyCodes property. Keeping 23001 also there makes it work for previous version as well. HTH, --oleg -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
