hello to all..
i'm using hibernate 3.2.4sp1, hibernate annotations 3.3.0 and hibernate validator 3.0.0 and spring 2.0.5
i have 2 junit test case
one inserting a 1000+ length string to a 80 column
and
one inserting "com.com" to a a property marked with
hibernate annotation's @Email
of course both will fail, throwing an exception when i do
session.flush()
ok
all is good
but i', using spring with annotation based transaction
i've notice the problem here
in hibernate's code
org.hibernate.engine.ActionQueue lines 231 - 238
Code:
private void executeActions(List list) throws HibernateException {
int size = list.size();
for ( int i = 0; i < size; i++ ) {
execute( (Executable) list.get(i) );
}
list.clear();
session.getBatcher().executeBatch();
}
the invalid email throws an com.hypercart.model.dao.hibernate.InvalidStateTranslator at
execute( (Executable) list.get(i) );
while the invalid length code
throws a HibernateException based exception
at
session.getBatcher().executeBatch();
so the list is cleared
anyways the List is a list of insert statements
when the list is not cleared, spring's aop does a commit at the end of the
transaction function resulting in a commit
and the exception is thrown again..
so my question is
shouldn't the list of insertion be cleared whenever you fail a commit?
i mean
what i want is
and that is what happens when i insert a long string
does not fail hibernate validator but fails the actual database insert
insert ....
commit
--error
commit
--ok
commit
--ok
commit
--ok
but when the entity fails the hibernate validator, this is what happens
insert ....
commit
--error
commit
--error
commit
--error
commit
--error
any information on why this behavior is different?
shouldn't a fail insert be consistent?
consistently clearing the list of pending updates?