Menu

setBeanManager((HibernateBeanManager)...)

Help
2009-03-15
2013-04-19
  • JNameNotTaken

    JNameNotTaken - 2009-03-15

    Hi All

    I'm new to hibernate4gwt. I'm using it rather than the newer version Gilead because the tutorial to get started is better.

    I've worked with hibernate successfully before but my understanding is limited.

    On the tutorial here: http://hibernate4gwt.sourceforge.net/getting_started_stateless.html
    the following is used:

    public UserRemoteImpl()
    { setBeanManager((HibernateBeanManager)ApplicationContext.getInstance().getBean("hibernateBeanManager"));
    }

    I can't get this going, in any case I don't want all the stuff from the testApplication. I want to run in stateless mode.

    What can I do to setBeanManager(..) simply in stateless mode.

    I apologize in advance if this question has been asked before. I've searched in depth but cannot find the solution.

    Thanks Very Much
    J

     
    • JNameNotTaken

      JNameNotTaken - 2009-03-16

      Ok, for anybody interested here is the solution:

      In your HibernateUtil file:

      private HibernateBeanManager hbm;   //declare a member

      public static getHibernateBeanManager() { //get method for the member
         return hbm;
      }

      public static SessionFactory getSessionFactory() { //returning your session factory
         .......
         hbm = HibernateBeanManager.getInstance();
         hbm.setSessionFactory(sessionFactory);  //as per the hibernate4gwt tutorial
         return sessionFactory;
      }

      In your server side implementation of the GWT service
      (E.g.)
      public class ServerGatewayServiceImpl extends HibernateRemoteService implements
              ServerGatewayService {

            public ServerGatewayServiceImpl(){
                 setBeanManager( HibernateUtil.getHibernateBeanManager() );
            }

            //other implemented methods to interface GWT here

      }

      This worked for me. Fingers crossed that it is in fact correct.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.