• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Seeking simple Spring MVC + Hibernate + MySql + Tomcat tutorial/working project

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have wasted the alst 3 days putting jar files in various tutorials , yet they do not work.

Spring 3 + Hibernate 4 + MySql + Tomcat + Eclipse Indigo = thsi is what I have on my computer


Can anyone please give me a project that works ? The best would be a tutorial so I can read the explanations too.

I know how to make a simple Spring / Hibernate application , but I do not know (have problems) combining them.

Can anyone please help ?
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi cod,

Welcome to coderanch!

There's a dedicated forum for Hibernate/Spring where you can get better help.

Secondly, this is NotACodeMill, so please post what have you tried till now, what you want to achieve, and exactly where you are facing an issue.

I hope this helps.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anayonkar Shivalkar wrote:
There's a dedicated forum for Hibernate/Spring where you can get better help.


Thanks! moved it to the right forum.
 
Myke Enriq
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So here is my exact problem: I learned how to make a simple Hibernate+MySQL class/table mapping , I also learned how to make a simple Spring MVC application.

- simple Hibernate mapping program = 1 hibernate.cfg.xml + 1 Mapped_class.xml + 1 mapped_class.java + 1 main.java + 1 returnSessionFactory.java class
- simple SPring MVC application = 1 web.xml + 1 dispatcher-servlet.xml + 1 controller.java + 1 page.jsp file

The thing is I want to make a simple SPring MVC application that uses Hibernate to map a class over a table and insert/delete CRUD system on that table.

How do I do that ?:

- first I cannot find a tutorial/example that actually works (with the jars of Spring 3/ Hibernate 4/ Eclipse Indigo/MySQL). Anyone know a new tutorial(tutorial for these versions of jars) ?

- wasted a ton of time trying to make some examples run by adding jars on them only to get compatibility issues. Anyone knows a working project ?

- how do I connect the web.xml with the hibernate.cfg.xml ? Is there a free tutorial explaining this ?

- what happen with the returnSessionFactory.java class ? In all SPringMVC + Hibernate tutorials I see this class does not exist , it is embedded in the web.xml or some other .xml file as the SessionFactory bean. Anywhere I can get more information on this (like how Spring links the beans) ?

Thank you for your answers and for your time , please help me if you can.
 
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
Unfortunately, to fully explain it all would take a lot of time. So I am going to just do the basics.

1) Do you understand Spring and Spring configuration?

If you do then this will make sense.

Basically to integrate Hibernate with Spring, and that also means a Spring MVC application. Is to configure and start Hibernate via Spring configuration.

To do that you basically create a <bean> where you use Spring's LocalSessionFactoryBean or AnnotationSessionFactoryBean class as the class="" part of the <bean> tag.

Then you just set that bean's properties. In this case, you don't need a hibernate.cfg.xml file anymore, all that configuration is now in that <bean> tag. That is typically how you integrate Hibernate in Spring. It is all documented in the Core Spring documentation. Under the data sections, right after jdbc. (FYI, you can also set a property of those FactoryBean classes to point to the hibernate.cfg.xml file)

Look at the section 13.3 Hibernate here for more info on the FactoryBean configuration.

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html

You can also have Spring automatically do a lot for you with Spring ROO.

Remember to check your private messages for that important message from us moderators.

Mark


 
Myke Enriq
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok , I wrote a simple SpringMVC+Hiberante example, wrote the xml to configure the MVC stuff and hibernate and sessionFactory , I added all the jars for it to run , but when I run it the following error appears:

exception:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.context.request.ServletRequestAttributes.updateAccessedAttributes()

root cause:

java.lang.NoSuchMethodError: org.springframework.web.context.request.ServletRequestAttributes.updateAccessedAttributes()



The thing is I searched bit on the web, the jars I added may not be compatible;
Here are the jars in my project , please tell me your opinion:

antlr-2.7.6
aopalliance-1.0
commons-collections-3.1
commons-dbcp-1.1
commons-logging-1.1.1
commons-pool-1.3
dom4j-1.6.1
hibernate-jpa-2.0-api-1.0.1
hibernate3
javassist-3.12.0
jta-1.1
mysql-connector-java-3.1.11
org.springframework.aop_3.0.5
org.springframework.asm_3.0.5
org.springframework.beans_3.0.5
org.springframework.context_3.0.5
org.springframework.context.support_3.0.5
org.springframework.core_3.0.5
org.springframework.expression_3.0.5
org.springframework.web_3.0.5
servlet-api
slf4j-api-1.6.1
spring-2.0-rc3
spring-dao-1.2
spring-hibernate3-2.0.3
spring-webmvc-3.0.5
 
Myke Enriq
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone got any ideea on what jar are not compatibile here ?
 
Mark Spritzler
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
All of these look suspect to me

spring-2.0-rc3
spring-dao-1.2
spring-hibernate3-2.0.3
spring-webmvc-3.0.5

But the easiest way to get the jars is to use something like maven or gradle and add the dependencies there like



The I just set the spring.version in the pom file to what version of Spring I want to use.

Mark
 
Tell me how it all turns out. Here is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic