aspose file tools*
The moose likes Spring and the fly likes Insert In SpringMVC 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 "Insert In SpringMVC " Watch "Insert In SpringMVC " New topic
Author

Insert In SpringMVC

Arian Zand
Greenhorn

Joined: May 28, 2012
Posts: 9
Hi I have a Webapp and i want to insert a record in my db
This is my controller


tis is my dao


my daoImpl

When I press on save in my view it doensn't insert a new record in my db

I have no errors, the webpage goes back to my home.jsp...

Someone who knows what im doing wrong ?

Thanks!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Try adding a debug statement/println to ReservationMaken2(). Does it get run?

Also, not that it is Java convention to have method names begin with lowercase. So you'd have reservationMaken2().


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

What is your JPA configuration? Have you properly set up your transaction manager?

I would turn up the logging in javax.persistence, in org.springframework.orm and see what it tells you. Bottom line if the transaction manager isn't configured right it will not flush and therefore will not cause a push of the data.

I also don't see a @Transactional anywhere. What is your transaction configuration? Are you using the AOP driven one or <tx:annotation-driven/> in your XML?

Ken

Ken Rimple
ken.rimple@gmail.com
Co-author, Manning Spring Roo in Action
I teach for Chariot Solutions (Spring, Maven, Hibernate, other courses). Schedule here
Arian Zand
Greenhorn

Joined: May 28, 2012
Posts: 9
Ken Rimple wrote:What is your JPA configuration? Have you properly set up your transaction manager?

I would turn up the logging in javax.persistence, in org.springframework.orm and see what it tells you. Bottom line if the transaction manager isn't configured right it will not flush and therefore will not cause a push of the data.

I also don't see a @Transactional anywhere. What is your transaction configuration? Are you using the AOP driven one or <tx:annotation-driven/> in your XML?

Ken

Hey Ken,

My JPA do you mean my persistence.xml? (I search on the internet what the JPA was standing for i didnt know...)
If my jpa is my persistence.xml I dont know where to find this file...
And where do i need to set the annotation Transactional ?
Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

If you don't know those pieces of information, I can't help as much...

You need to find out where your Spring configuration files are, usually called applicationContext.xml or something like that. They'll usually live in the src/main/resources directory of your application somewhere, sometimes in there as META-INF/spring, (I'm assuming Maven here). Did you have SpringSource ToolSuite set it up for you? In that case, that's the directory. If not, did you use Roo? Same place...

The persistence.xml file is where you define your JPA configuration, such as the JPA provider and mapping information. The applicationContext would be using an EntityManagerFactoryBean to create the entity manager, and that's where the JPA config is. Then you'd mount a transaction manager in the same configuration file.

You may need to read up on these things to understand why you're getting the behavior you're seeing - the Spring Framework documentation is quite good, as is Craig Walls' Spring in Action book for example (not a plug, but he goes through these things in great detail).

I suspect you don't have everything wired properly and that's why nothing is being persisted.

If you have Roo build you a JPA-based application, such as running 'script wedding.roo' - you'll see how they organize their configuration, although they use AspectJ for the transaction management, which can make learning from it a tad tricky.

Ken
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Insert In SpringMVC