In my Seam app, I upload a file, create a record for it in the DB, persist() 
and flush() it, then move the file to a folder for processing.

The problem is that sometimes my file processing application gets the file 
before the record is visible in the DB.

There isn't anything else happening in the method after moving the file, but 
apparently, Seam isn't quite speedy enough on committing the Transaction.

There is no @PostCommit event, and @PostPersist is still too early. What I'd 
like to do is just commit the Transaction, then move the file. However, 
entityManager.getTransaction() throws "java.lang.IllegalStateException: JTA 
EntityManager cannot access a transactions".

How do I move my files after the Transaction is committed? All I can really 
think of is manually committing the Transaction, but that doesn't seem to be 
allowed. Is there a way to do it? I don't want ALL my Transactions to require 
manual commit, just this one instance. Do I need to create a second 
core:managed-persistence-context in components.xml that points to a different 
persistence-unit in persistence.xml?

Or is there some other way of doing this? I've seen the @Asynchronous 
annotation. If I call a method annotated with this from within a Transaction, 
am I guaranteed that it won't be triggered until after the Transaction has 
committed?

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089082#4089082

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089082
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to