Obtaining EM properties outside a transaction [message #548184] |
Tue, 20 July 2010 22:14  |
Eclipse User |
|
|
|
I need to know, for instance, which kind of database my entity manager is referencing (mysql, oracle..).
The code below is an aproach:
Session session = em.getSession();
if (session.getDatasourcePlatform().isOracle()) {
....
}
But, I need to put this code inside a method that is not in a transaction context. More precisely, I need to obtain this information inside a EJB method with transaction type supports.
The code above doesn't work outside a transaction context, because the session is null. Is there a way to obtain this information (or other entity manager property) without a transaction? Can I obtain the session without being inside a transaction context?
Thanks. Mauro.
|
|
|
|
|
|
Re: Obtaining EM properties outside a transaction [message #549044 is a reply to message #548967] |
Fri, 23 July 2010 15:53  |
Eclipse User |
|
|
|
Chris
- em.isOpen, em.contains - didn't change anythis.
- getDelegate() - do not return null
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List<AlunoED> lista(AlunoED alunoED, PropriedadesLista qp) {
System.out.println("em is open: " + em.isOpen() );
System.out.println("em contains: " + em.contains(alunoED));
EntityManager emdelegate = (EntityManager) em.getDelegate();
System.out.println("em delegate: " + emdelegate);
try {
Session session = JpaHelper.getEntityManager(emdelegate).getSession(); // 1
System.out.println("session = " + session );
} catch (Exception e) {
System.out.println("session - exception " + e.getMessage() );
}
....
I'll open a call to Oracle. The application server is weblogic 11g.
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.25623 seconds