• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Spring & HIbernate Integration

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

Just want to know how to integrate spring & hibernate in an web application.I googled and found the following.
1. Configuring webapplicationcontext as a context listener in web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

In one of applications which we support they have used spring,hibernate & EJB also.But, i was not able to find the above configuration in web.xml.Rather i found something as follows:

<bean id="UserEJBBean" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" lazy-init="true">

<property name="jndiName">
<value>ManageUserEJBJNDI</value>
</property>
<property name="businessInterface">
<value>.....<package>..............ManageUserEJB</value>
</property>
<property name="lookupHomeOnStartup" value="false"/>
</bean>

I can understand from the above code, that "SimpleRemoteStatelessSessionProxyFactoryBean" is used for JNDI lookup.
From the managed bean,the lookup is as follows: Mangedbean --> EJB --> (service layer) Interface --> Impl --> DAO (Interface & Impl) --> Hibernate --> DB etc..

Now, my doubt is how spring is integrated with hibernate here?? Is there any other way??
I am really confused.
Please, please help me understand.

Thanks a lot for your time



 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hibernate is integrated into Spring by having a bean in your Spring configuration file where the class is LocalSessionFactoryBean or one of its subclasses. This is not in your web.xml.

This FactoryBean creates a Hibernate SessionFactory.

Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic