users@glassfish.java.net

Re: Hibernate + ConnectionPool

From: <glassfish_at_javadesktop.org>
Date: Tue, 24 Aug 2010 04:41:49 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.

[b]I looked at documentation and followed it exactly, documentation suggests that i also include the name property for the SessionFactory name="hibernate/SessionFactory" in the hibernate configuration file[/b]

> 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"/>

[b]I'm using annotation for hibernate in my bean and referencing the bean in the hibernate configuration file.[/b]

> 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();

[b]so my application has to be deployed to glassfish server in order to be able to do the JNDI lookup! what if i have desktop application and wanted to access connectionpool?[/b]

> HTH.

[b]Thank you for taking the time.[/b]
[Message sent by forum member 'java_on_fire']

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