my dog learned polymorphism*
The moose likes Spring and the fly likes spring + hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring + hibernate" Watch "spring + hibernate" New topic
Author

spring + hibernate

manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Hi,

I have some trouble with integrating Spring and Hibernate.
First, I use JPA annotation near an entity to create db schema. My code works fine for hibernate alone. I have no persistance.xml. I hope that it isn't necessary.

Now I am trying integrate spring but I have probably a mistake in applicationContext.xml. I would like to use a solution similar to "13.3.2 Implementing DAOs based on plain Hibernate 3 API" on springframework.
Could anyone help to beginner?



My applicationContext.xml



My hibernate.cfg.xml:





My error log:


I would appreciate any help.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Why do you define two SessionFactories in your config file. The error that you are receiving is coming from the first one, because you did not put the location of the hbm.xml into the hibernate.cfg.xml.

First choose one bean to define for us, then we can help you get that to work if it doesn't work.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Mark Spritzler wrote:Why do you define two SessionFactories in your config file. The error that you are receiving is coming from the first one, because you did not put the location of the hbm.xml into the hibernate.cfg.xml.

First choose one bean to define for us, then we can help you get that to work if it doesn't work.

Mark


Thank for reply.

I prefer use JPA annotations therefore I think the AnnotationSessionFactoryBean would be better for me. I have a few experiences in hibernate mapping via xml configuration files.
I would like to use declarative transactional annotation as well.

So I have edited applicationContext.xml. (All other files are without changes):


Log:

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

OK, so it looks like you have your configuration all set up and correct.

The error you are getting is now specific to JPA/Hibernate and not a Spring issue. There is something wrong with your Mapped class. It looks like you didn't set the @GeneratedValue for the @Id correctly or, the database that you are connecting to does not have the Table in it that you are mapping your class to.

Mark
manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Mark Spritzler wrote:OK, so it looks like you have your configuration all set up and correct.

The error you are getting is now specific to JPA/Hibernate and not a Spring issue. There is something wrong with your Mapped class. It looks like you didn't set the @GeneratedValue for the @Id correctly or, the database that you are connecting to does not have the Table in it that you are mapping your class to.

Mark


It works ! Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring + hibernate