-
1. Re: entity update on postgres corrupts booleans
asookazian Jul 27, 2009 10:30 PM (in response to guy_cole)so your question becomes what is the root cause of the following behavior:
When I fetch a lazy collection, after the fetch there is a update (which corrupts my boolean values).Are you using JPA with Hibernate as persistence provider or other provider? Are you using AUTO, COMMIT, or MANUAL flushMode? Show code example.
If you have time, etc., using hbm2ddl (Hibernate Tools) you can forward-engineer your JPA entities into a different db (like mysql, MSSQL, etc.) and see if you can reproduce the behavior.
-
2. Re: entity update on postgres corrupts booleans
guy_cole Jul 27, 2009 10:58 PM (in response to guy_cole)OK, I fixed it.
Thank you very much for your prompt and appropriate response.
I switched flush-mode to
MANUAL
(from the conversation) and now it seems to behave properly.To answer your other questions, it is JPA and the code is not very interesting. Something like this:
public class Entity {
boolean flag
//setter and getter for flag@OneToMany(yadda...)
public Set getCollection() { }
public void setCollection(Set arg) { }
}I call the collection from a toggle panel, which reads the collection (for display as a table). After the read, there would be a gratuitous update w/bad boolean values written to DB.
I can send you something prettier if you like.
Thank you very much. I spent all day yesterday trying to figure this out. Great relief to have a simple solution.
-
3. Re: entity update on postgres corrupts booleans
asookazian Jul 27, 2009 11:55 PM (in response to guy_cole)It's very important to understand why that fixed it (i.e. what is the difference b/n AUTO and MANUAL?)
You should typically use MANUAL in Seam apps (if Hibernate is your persistence provider) as it enables you to achieve the atomic conversation covered in SiA book.
We typically use SMPC (@In EntityManager entityManager;) with MANUAL flush in our conversation modeling...
-
4. Re: entity update on postgres corrupts booleans
swd847 Jul 28, 2009 1:16 AM (in response to guy_cole)Are you sure it is fixed? When you manually do entityManager.flush() does it write the booleans ok?
If there is still a problem can you post how your booleans are mapped?
-
5. Re: entity update on postgres corrupts booleans
guy_cole Jul 28, 2009 1:31 AM (in response to guy_cole)Yes, quite sure joining the conversation cures this issue.
I don't do a flush() because I don't ask for the update. The update was just something which happened after I read the collection.
I'm guessing that without the join/conversation, something decided the entity was dirty and required synchronization (after doing the lazy collection read). I spent a lot of time on this. Only booleans were corrupted. Strings and integers were fine.
Now w/a conversation, there isn't any update and no chance of corruption.
Originally, I didn't join a conversation from this page because there is not any editing, only viewing. Some parts of the page are in (a closed) simpleTogglePanel. The collection is read when the panel is opened, causing a select and then a gratuitous update.
Now I have a join conversation around the page and it works.
Thanks for asking, hope this answers your question.