【发布时间】:2012-03-24 13:10:21
【问题描述】:
我有以下设置。
类,例如具有 CarPart (belongsTo=[car:Car]) 的 Car。
当我创建汽车时,我还想创建一些默认的 CarParts,所以我这样做了
def car = new Car(bla bla bla)
def part = new CarPart(car:car)
现在,当我执行 car.validate() 或 part.validate() 时,它似乎很好。 但是当我这样做时 if(car.save && part.save() 我得到了这个异常:
2012-03-24 14:02:21,943 [http-8080-4] ERROR util.JDBCExceptionReporter - Batch entry 0 insert into car_part (version, car_id, id) values ('0', '297', '298') was aborted. Call getNextException to see the cause.
2012-03-24 14:02:21,943 [http-8080-4] ERROR util.JDBCExceptionReporter - ERROR: value too long for type character varying(6)
2012-03-24 14:02:21,943 [http-8080-4] ERROR events.PatchedDefaultFlushEventListener - Could not synchronize database state with session
org.hibernate.exception.DataException: Could not execute JDBC batch update
Stacktrace follows:
java.sql.BatchUpdateException: Batch entry 0 insert into car_part (version, deal_id, id) values ('0', '297', '298') was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2621)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1837)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2754)
at $Proxy20.flush(Unknown Source)
at ristretto.DealController$_closure5.doCall(DealController.groovy:109)
at ristretto.DealController$_closure5.doCall(DealController.groovy)
at java.lang.Thread.run(Thread.java:722)
有什么想法吗?
【问题讨论】:
标签: postgresql grails grails-orm grails-domain-class