I am using Seam 1.2 GA + JSF + Apache 6 and I got some problems in handling transactions. I tried hard to find when Seam opens, commit and flushes an transaction during a request without success.
Why Seam commits/flushes a transcation when I do em.find(clazz,id) ?
I have a transient object (an user instance) inside a managed object (Issue instance, for example), so I need to get a managed user instance, for that, I use em.find and I got a really nice Transient Object Exception because someone tryies to flush the transction during em.find.
You could think that I only need to do merge() instead of trying to find() but in my case, the user instance will be always transient because it cames from a legacy system and if it exists in my system I have to merge otherwise I have to insert it.
I solved this problem setting manual flush mode but it is too boring to work with.
Other problem I have is undesirable commits after Ajax requests causing transient object exception.
Anyone knows how to solve these questions in a better way ?
Manual flush mode is the way to handle this. Read the JPA spec/a good book like Java Persistence with Hibernate by Christian (Bauer) for why it works like it does.