Domain validates but won't save
Posted
by
marko
on Stack Overflow
See other posts from Stack Overflow
or by marko
Published on 2012-03-24T13:10:21Z
Indexed on
2012/03/26
11:29 UTC
Read the original article
Hit count: 206
I have the following setup.
Class, say, Car that has a CarPart (belongsTo=[car:Car]).
When I'm creating a Car I also want to create som default CarParts, so I do
def car = new Car(bla bla bla)
def part = new CarPart(car:car)
Now, when I do car.validate() or part.validate() it seems fine. But when I do if(car.save && part.save() I get this exception:
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)
Any ideas?
© Stack Overflow or respective owner