aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring Hibernate Communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring Hibernate Communication" Watch "Spring Hibernate Communication" New topic
Author

Spring Hibernate Communication

San Nan
Greenhorn

Joined: Jul 01, 2005
Posts: 22
Dear All,

I am New to Spring & wants an application source for communicating with hibernate.

Please provide me the help for how to communicate Spring+Hibernate+mySql.


Thanks & Regards

San Nan
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

Let me introduce you to my little friend, Google ...


Junilu - [How to Ask Questions] [How to Answer Questions]
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

You may like to see this link:
http://jdj.sys-con.com/read/140097_p.htm.

Also to make your life simpler, pickup any Spring example and replace DAO object with your hibernate classes. Think hibernate integration as of adding a DAO class.
San Nan
Greenhorn

Joined: Jul 01, 2005
Posts: 22
This link is not working
Srinivasa Kadiyala
Ranch Hand

Joined: Jun 10, 2004
Posts: 237
Yes I too tried. The link is not working


Srini
Magesh Lakshmi
Greenhorn

Joined: Nov 02, 2005
Posts: 10
Send me an email , if you need code samples on how to use this one.


Mag
Clodoaldo J�nior
Greenhorn

Joined: Nov 12, 2005
Posts: 3
Dear San Nan,

Integrate Spring framework with Hibernate and any database is very simple.
You must to declare a configuration database in application configuration file as follow:

<!-- Data source bean -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>org.postgresql.Driver</value></property>
<property name="url">
<value>jdbc :p ostgresql://localhost/mydatabase</value></property>;
<property name="username"><value>bonovox</value></property>
<property name="password"><value>u2forever</value></property>

</bean>

<!-- SessionFactory bean --!>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<value>product.hbm.xml</value></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
net.sf.hibernate.dialect.PostgresSQLDialect</prop>
</props>
</property>
</bean>

After, you only use hibernateTemplate in your code to make available the CRUD operations in your applications. hibernateTemplate is obtain through class org.springframework.orm.hibernate.support.HibernateDaoSupport called method getHibernateTemplate().

[]'s ClodoaldoJR

[ November 12, 2005: Message edited by: Clodoaldo J�nior ]

[ November 12, 2005: Message edited by: Clodoaldo J�nior ]

[ November 12, 2005: Message edited by: Clodoaldo J�nior ]

[ November 12, 2005: Message edited by: Clodoaldo J�nior ]
[ November 12, 2005: Message edited by: Clodoaldo J�nior ]

UFPB - University Federal of Paraiba - Brazil (bachelor degree)
 
wood burning stoves
 
subject: Spring Hibernate Communication