File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate and PostgreSQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate and PostgreSQL" Watch "Hibernate and PostgreSQL" New topic

Hibernate and PostgreSQL

Ravi Shankar Mukkavilli

Joined: Feb 10, 2009
Posts: 12
Hello All,

I'm not really sure if I can ask this question in this forum. Anyway, I'm trying to connect to a PostgreSQL db through hibernate 3 and create a simple table. I'm able to run the code without any error, but no table is getting created. Of course Hibernate related output are not getting generated. Here is the code.

and here is the hibernate.cfg.xml file

I'm able to run and create a table successfully against a MySQL server. Is there any thing wrong with the way the db is set up. Please do take a look at the screen shot.


[Thumbnail for PostgreSQL.PNG]

SCJP 1.4
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Your hibernate.cfg.xml doesn't have the mapped class listed in it

You need either

<mapping package="com.model"/>


<mapping class="com.model.User "/>

the first will find all Mapped classes in the com.model package. Whereas the second will just use the one mapped class.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Ravi Shankar Mukkavilli

Joined: Feb 10, 2009
Posts: 12
Thanks for the reply, I did update the hibernate.cfg.xml file and added this

the result was same, the code ran without errors and no table was created.

I agree. Here's the link:
subject: Hibernate and PostgreSQL
It's not a secret anymore!