-->
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.  [ 1 post ] 
Author Message
 Post subject: [JBoss] Explicitely defining mapper classes using MBean
PostPosted: Fri Mar 24, 2006 12:21 pm 
Newbie

Joined: Wed Feb 22, 2006 9:30 am
Posts: 13
Location: Cologne, Germany
Hi,

I'm not quite sure whether this is a Hibernate or a JBoss issue, so I'll just post the question here. I'm having a little trouble defining a working and conceptionally correct way of configuring the database access from within a EJB.

As background: Currently, I'm running a servlet in which a couple of Manager classes are stored, which implement my business logic. The controller servlet calls these business logics and then passes the results to a JSP for presentation.

One of these Manager instances is a DatabaseManager which at initialization reads a few property files and builds up a series of SessionFactory instances to a series of databases.

Now I want to port the complete application to J2EE, where each manager will be an EJB3 stateless bean.

My question right now is: How to I set up the hibernate configuration correctly? The goal is to do something like this:

Code:
  @javax.ejb.Stateless
  public class FooManager {

    public int bar(String databaseName) {
      SessionFactory factory      = Helper.getSessionFactory(databaseName);
      Session session             = factory.openSession();
      try {
        int queryResult           = AnotherHelper.countRecords(session);
        return queryResult;
      } finally {
        session.close();
      }
    }

  }


I experiemented a little bit using the Hibernate MBean configuration but haven't got the clue completely. The mapper classes I've stored within my application JAR archive should be mapped to different databases, so this also means SessionFactory instances, so I need to be able to manually control which mapper class should be used during the initialization of each SessionFactory.

But so far I can't find any part within the existing documentation that describes how to explicitely map classes to a SessionFactory.

Are there any tutorials available that describe this kind of setup?[/code]


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

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.