• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Obtain JDBC Connection in SessionBean using JTA.

Maciej Miklas
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic