-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate, JBoss and SessionContext name collision
PostPosted: Sun Sep 05, 2004 8:46 am 
Newbie

Joined: Sat Aug 28, 2004 11:49 am
Posts: 4
Location: Amsterdam
Hi,

I'm beginning to enjoy 3.2.6 and the new HAR stuff. My entities are now all hibernate POJOs, and I'm moving on to the manager/controller layer (almost totally SLSBs).

However, there are two things about the boilerplate, I'd be grateful for opinions on...

Code:
public abstract class MyStatelessController implements SessionBean, MyController {

   protected static final String HIBERNATE = "java:/hibernate/SessionFactory";
   
   /** */
   protected SessionContext ctx;
   
   /**
    * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
    */
   public void setSessionContext(SessionContext ctx) {
      this.ctx = ctx;
   }
   
   /**
    *
    * @return
    */
   protected Session getSession() {
      return org.jboss.hibernate.session.SessionContext.getSession(HIBERNATE);
   }
   // ...and so on
1) What's the best way to get the static final String out of my SLSBs?
2) When using Session Beans I keep a copy of the context, but that causes annoying name collisions between org.jboss.hibernate.session.SessionContext and javax.ejb.SessionContext.

Any pointers?

/k1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 4:54 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
Just wrap getSession() with your own class, say, HibernateSession.

It's always useful in case you have several options to get the session (for example, from local hibernate instance in testing and jboss service in production).

Anyway, renaming SessionContext may be a good idea, since all EJB's import javax.ejb.SessionContext by default and it really confusing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.