We help IT Professionals succeed at work.
Get Started

spring - hibernate best practises

royjayd
royjayd asked
on
552 Views
Last Modified: 2013-11-24
hi guys,

i am building a real time application and was just trying to understand whats a good way to impliment it in spring and hibernate.
I was reading this article on it:

http://www.javabeat.net/articles/42-integrating-spring-framework-with-hibernate-orm-framewo-1.html

This above article uses Hibernate objects as Spring Beans, so that means hibernate objects will be defined in spring configuration file as beans.

But my application architecture is this:

jsp--> SpringConfigFlie --> Validatior calss ---->Controller class-->  business delegate->dao-->hibernate-->DB

Therefore in my architecture i am not calling hibernate until i reach the DAO.
comparing my architecure with the one in article, which one is better  and why?

Also in the article the database configuration is done in spring config file like this
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" >
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost/samples"/>
    <property name="username" value="root"/>
    <property name="password" value="pwForRoot"/>
</bean>

Is that good way to do it? I thought the database configuration is written in the hibernate config file (hibernate.cfg.xml).

There are too many resources on the web on spring-hibernate. Does anyone know how it is actually implimented in real tme projects ?

any responces/inputs will be greatly appreciated.
thanks.
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 3 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE