Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persisting the abstract

 
Cesar Sportore
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

PRODUTO.class


LIVRO.class


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
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error/issue do you get?

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

Try enabling logging on finest to debug issues.
 
Cesar Sportore
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

LivroRepository.class





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!
sourcenotfound.png
[Thumbnail for sourcenotfound.png]
Source not Found
 
Emanuel Kadziela
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic