Here is what I would like to do:
This is my bussiness interface:
package pl.com.filmservice.ejb;
|
| import java.sql.Date;
| import java.util.List;
| import pl.com.filmservice.par.*;
|
| public interface FilmService
| {
| ...
| public void createUser(User user);
| ...
| }
and the implementing bean:
package pl.com.filmservice.ejb;
|
| import java.sql.Date;
| import java.util.List;
| import java.util.ArrayList;
| import javax.ejb.*;
| import javax.persistence.*;
| import pl.com.filmservice.par.*;
|
| @Stateless
| public class FilmServiceBean implements FilmService
| {
| @PersistenceContext(unitName="FSWise")
| EntityManager em;
| ...
| public void createUser(User user)
| {
| em.persist(user);
| }
| ...
| }
What I would like to do is to check if the em.persist(user) threw a pk
constraint violation exception, catch it and throw my own exception class so
that I can cathc it later on in the application.
The problem is that the transaction ends when the createUser method ends and
then the exception is thrown. I would like to catch it just after persist()
invocation.
I've tried to use EntityManager.createTransaction(), begin the transaction and
commit it just after the persist, but then i get the illegalStateException (i
can't call beginTransaction on the managed, injected EntityManager).
Any ideas about how to solve the problem?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3946544#3946544
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3946544
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user