I'm trying to experiment with Translators and I'm running into something I don't understand. I'm not sure if it is just a hibernate issue or something in the way that hibernate and Tapestry are interacting.
I have two classes: @Entity public class Quote { @ManyToOne(cascade = CascadeType.ALL) private Person person; //getters, setters, id and other fields } @Entity public class Person { @OneToMany(cascade=CascadeType.ALL) private List<Quote> quotes = CollectionFactory.newList(); //getters, setters, id and other fields } I'm wanting to create a translator that lets me change the person associated with a particular quote in a simple text field in a BeanEditForm. If you create a quote and type the name of an existing Person object, it should use the existing person. If you type in the name of a new person it should create a new person. Here is the relevant part of the translator: public Person parseClient(Field field, String clientValue, String message) throws ValidationException { Person person = null; //If the person already exists pull them out of the database person = (Person) session.createCriteria(Person.class).add(Restrictions.ilike("name", clientValue)).uniqueResult(); //If they they don't exist create a new person with the new name if(person == null) { logger.info("Person is null after db call- creating new person"); person = new Person(); person.setName(clientValue); } return person; } The page that handles the BeanEditForm is very simple: @CommitAfter Object onSuccess() { logger.error("person id = " + quote.getPerson().getId()); session.persist(quote); return "admin/AdminIndex"; } Everything works just fine when I create a new Quote. A new person is created and added to the database. However, if I load up an existing quote and type in a different name I get: [WARN] util.JDBCExceptionReporter SQL Error: 0, SQLState: null [ERROR] util.JDBCExceptionReporter failed batch [ERROR] def.AbstractFlushingEventListener Could not synchronize database state with session org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) This happens regardless of whether I type in the name of a new person or one that is already in the database. I looked at the hibernate debug statements and at first I thought that when adding a new Person it might be trying to update the Quote before the new Person was saved. I tried explicitly saving the new Person first, but that didn't help. Also, I get the same error when trying to use the name of a person that is already in the database. I can see from the debugging that it grabs the right person out of the database, but I get the same error right after it shows the SQL that will update the PERSON_QUOTE table that links the id of a person to the id of the quote they made. I have spent several hours going through the Hibernate forums trying the solutions for everything similar, but nothing seems like an exact match and none of the suggestions seemed to work. Is there something I'm overlooking about how Tapestry handles things that might be causing this? Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org