users@glassfish.java.net

Re: Hibernate + ConnectionPool

From: <glassfish_at_javadesktop.org>
Date: Mon, 23 Aug 2010 23:23:33 PDT

In your application, there should be a hibernate.cfg.xml where you should specify the hibernate.connection.datasource to a value that points to the jdbc resource you created for this connection pool. There could be other properties in this file for which you need to refer to the hibernate documentation.

If you have a bean called "Employee.java", you would have a corresponding Employee.hbm.xml file in which all the bean attributes are written as <property> elements. This Employee.hbm.xml can be mentioned in the hibernate.cfg.xml as
<mapping resource="com/employee/Employee.hbm.xml"/>
If you have a stateless session bean, you can annotate the bean with @Stateless(name="asdfasf") and implement a Local interface. You could write some utility methods to access this Employee.class and this can be used in the stateless session bean to do some operations.

The descriptor web.xml could have the ejb-local-ref element with the <ejb-ref-name> <ejb-ref-type> and <local> elements, along with a welcome file (jsp file). sun-web.xml would include the context root for the web-uri. In the jsp file, you could do

InitialContext ctx = new InitialContext();
MySessionBeanLocal bean = (MySessionBeanLocal) ctx.lookup("java:comp/env/ejb/MySessionBean");
bean.test();

HTH.
[Message sent by forum member 'sm157516']

http://forums.java.net/jive/thread.jspa?messageID=480855