This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Need help setting up Hibernate

 
Ranch Hand
Posts: 39
2
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to add Hibernate JPA to my webapp, and I am having two problems.

1) There's an error message by the @Entity annotation on the Person.class. It says, "The table Person cannot be resolved"
2) I can't create a SessionFactory in the TestEntityManager class, so my tests never run. An exception is thrown when the EntityManager is created, but the SessionFactory is null. I'm not sure if the EntityManager exception is related to the null SessionFactory.

In regards to the Person.class error, I tried a few different solutions. I tried a couple from here: http://stackoverflow.com/questions/7475228/problem-with-jpa-project-in-eclipse-error-in-class-annotated-entity-table-x. I don't want to turn off the validator, because that seems useful. I tried using the JPA tools to create tables from entities, but I got the following stack trace:



I also tried the solution from this link: http://stackoverflow.com/questions/7865753/eclipse-reports-error-on-my-jpa-project. I tried refreshing my connection to the DB using the JPA view, but the error didn't go away. I am able to ping by DB from the  view. I can also see my DB using pg admin. Do you have any other ideas on how I can create the Person table? What am I missing?

Now for the second problem. I tried to make a Util class for creating the SessionFactory, but I'm not sure where I have gone wrong. Can you take a look at my configurations and tell me if they are correct? Do you thin the problem is in another class, or am I missing another class? thanks.

Here's the credentials that I used for logging into postgres


Person.class


Test Class. This is where the sessionFactory is set to null


This is where I implement the SessionFactory


persistence.xml


pom.xml


This is the output when i run the test class
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic