This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Persisting the abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Persisting the abstract" Watch "Persisting the abstract" New topic

Persisting the abstract

Cesar Sportore

Joined: Sep 18, 2012
Posts: 6
Hi guys,

I don't know if this is the appropriate place for this topic, but here I go:

I've been trying to make things a little more OO, so I used an abstract class to define a few default attributes and methods(getters/setters) for the subclasses, but I'm not used to work with inheritance on a JPA context and couldn't access/persist the fields belonging to the super class.
I've tried many things to solve my problem, but none of them worked out properly. This code I'm posting here is my current version of my workaround trials.



formulario-novo-livro.xhtml = this one is to register a new Livro(book) to the DB.

lista-de-livros = this one is to display all the books on the web page.

Thanks in advance to all who wish to help!
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
What error/issue do you get?

Ensure the Produto class is listed in your persistence.xml.

Try enabling logging on finest to debug issues.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Cesar Sportore

Joined: Sep 18, 2012
Posts: 6
Hi James!

Well, most of the times were Servlet Exceptions. Now the h:commandbutton simply won't work.
There was a time when I annotated the PRODUTO.class with @MappedSuperclass and I got a Conversion Exception at the Calendar field.
I'm pretty much lost, so I don't know if I can provide more useful info. What is the "enabling logging on finest"?
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
Set your log level to "all" or "trace" or at least "debug" so you can capture everything that is happening.

Who is your JPA vendor (Hibernate)? What does your persistence.xml file look like? What's the rest of the application configuration look like?
Cesar Sportore

Joined: Sep 18, 2012
Posts: 6
I've checked my log level and it's at FINEST level.

Yes, I use Hibernate. Here is an image of one thing that caught my attention.

And here are the files you asked for:


According to the Debugger, those are my classes that trigger the error. I'm pretty new to Java, so I don't know anything about debugging and stuff. If you guys have suggestions regarding literature that could help me I'd be very pleased!

Here is the persistence.xml:

Thanks for all the help!

[Thumbnail for sourcenotfound.png]

Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
You say "according to the Debugger" - what Debugger?

Are there any log files? Log output where the errors are printed? Those would be on the app server side, java logs with java errors. What is your application server (Tomcat)? You need to find, copy and paste the entire stack traces of your exceptions if you want someone to be able to help you. Just telling us "I'm getting exceptions" or "my stuff is not working" is not enough.
I agree. Here's the link:
subject: Persisting the abstract
Similar Threads
Action Event
JSF(managed) beans, can not work with JPA
JSF form problems
Passing parameters with h: link
Number of <h:form > tags on a page