This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF(managed) beans, can not work with JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF(managed) beans, can not work with JPA" Watch "JSF(managed) beans, can not work with JPA" New topic
Author

JSF(managed) beans, can not work with JPA

Zaeed McColin
Ranch Hand

Joined: Jan 13, 2009
Posts: 90
hi folks, I'm new in JSF
I developed a JSF application,
application is about a small library
okay, admin users can add new book to system(DB)
I do it with a method in a managed bean, but
some problems are here
codes
the bookAdd.jsp page (it's Okay)


and related managed bean (the problem specify with [x])

everything works okay, except addBook() method, id doesn't add any new record with JPA, or throws any exception, also it works till [x]
[0]:record(s) can not add to DB
[1]:this operation doesn't work(process)
*without any new record(s) or changes in database
*web server doesn't throw any exception

please help!


Open source
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17046
    
  26

My guess is that your transaction commit process isn't correct, but I don't do anything that's remotely like what you're doing.

First of all, I'm using DTO/Service classes to handle the persistence rather than attempting to jam everything into the backing bean.

Secondly, I use Spring to manage the DTO/Service instances. Spring can automatically provide the transaction management as well as the grunt work of cleaning up exceptions and stuff like that. And Spring and JSF play together quite well.

While I use more classes to get the work done, the individual classes are all simpler, since they only attempt to accomplish one thing, and they're enough like related classes in the same tier that it makes for easier maintenance and testing.


An IDE is no substitute for an Intelligent Developer.
Zaeed McColin
Ranch Hand

Joined: Jan 13, 2009
Posts: 90
wow, i solved it,
I just change my provider "OpenJPA" and use

instead of

and it works Okay
also thank you Mr. Holloway, I'd like to see an example of your solution
thanks anyway
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: JSF(managed) beans, can not work with JPA
 
It's not a secret anymore!