0
我有簡單的領域:如何捕獲grails.validation.ValidationException?
package app
class Customers {
String CUSTOMER
String NOTE
static mapping = {
version false
id column: 'ID_CUSTOMER', type: 'long',
generator: 'sequence',
params: [sequence: 'CUSTOMER_SEQ']
}
static constraints = {
CUSTOMER(nullable: false, blank: false, unique: ['NOTE'])
NOTE(nullable: true, blank: true)
}
}
列和約束正確地在數據庫中創建的(我想在客戶的約束,並注意在一起),但,不是得到:
grails.validation.**ValidationException**
我越來越:
Message: Hibernate operation: could not execute statement; SQL [n/a]; ORA-00001: unique constraint (TEST2.UNIQUE_CUSTOMER_NOTE) violated
; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (TEST2.UNIQUE_CUSTOMER_NOTE) violated
我不應該得到ValidationException約束違反時ED?
控制器代碼是由generate-all
腳本生成的標準自動代碼。
奇怪的部分是我有ValidationException當我試圖保存到兩個已存在的列值,但SQLIntegrityConstraintViolationException當只有一個已存在。 – marek 2014-12-04 17:59:47
數據庫中有行(ff,ff),另一個保存給出ValidationException – marek 2014-12-04 18:01:36
數據庫中有(ff,null),另一個保存給出SQLIntegrityConstraintViolationException – marek 2014-12-04 18:02:38