EJB programming & troubleshooting: Obtain JDBC Connection in SessionBean using JTA.

  1. Obtain JDBC Connection in SessionBean using JTA. (1 messages)

    Obtain JDBC Connection in SessionBean using JTA. Hi all, I have EJB2.1 + JDK5 + J2EE1.4 and weblogic9.2. I am currently using SessionBeans with hibernate. Hibernate is using JTA transactions – so the database connection is being controlled by application server, this is small example of such session bean: @Session(ejbName = "AlertService", transactionType = Session.SessionTransactionType.CONTAINER, type = Session.SessionType.STATELESS) @JndiName(remote = "ejb.AlertServiceRemoteHome") @FileGeneration(remoteClass = Constants.Bool.TRUE, remoteHome = Constants.Bool.TRUE, localClass = Constants.Bool.FALSE, localHome = Constants.Bool.FALSE) public class AlertService extends GenericSessionBean implements SessionBean{ @RemoteMethod(transactionAttribute = Constants.TransactionAttribute.REQUIRED) public String createBookmarkAlert(Object raw_freq, Set output, String userLogin) { org.hibernate.Session session = HibernateUtil.getSession(); …. This solution is great, because the transaction is being controlled on SessioBean level. Now i need to obtain JDBC connection, that also is being controlled by JTA – so it will automatically start, and rollback for me transactions. How to do it? Thanks, Maciej
  2. org.hibernate.Session session = HibernateUtil.getSession(); Conneciton con = session.connection() Do you see any problem over here? Anil.