File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Noob error :org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person] 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 "Noob error :org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]" Watch "Noob error :org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]" New topic
Author

Noob error :org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

I'm trying to set up a small working sample of Hibernate that I found here.
However when I run the code I get the follwing error
.

But I already have a table by the name person in the database and here's my hibernate.cfg.xml



Content of the postgresql log file


It would be great if anyone could point out what Im doing wrong, as this is my first attempt at Hibernate.
Thanks!


Learning and Learning!-- Java all the way!
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

UPDATE: Was able to fix that error. However I get the following error now



What I dont understand is why is hibernate looking at person0_ instead of person, any input on this could be helpful. Thanks!
Nanda P Kumar
Greenhorn

Joined: Aug 28, 2013
Posts: 1
It is because hibernate queries are later converted to sql queries and table aliases are created in the queries. In this case, person0_ is an alias for the table person.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Noob error :org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]
 
Similar Threads
onetoone unidirectional relationship problem
Hibernate: Mapping a sequence to a serial (autoincr) field (Postgresql)
insert proble postgrest
Weired error comes while using stored procedure with hibernate
Hell with postgres + hibernate