It's not a secret anymore!*
The moose likes Object Relational Mapping and the fly likes hibernate mapping question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate mapping question" Watch "hibernate mapping question" New topic
Author

hibernate mapping question

corneliu dabija
Greenhorn

Joined: Jun 08, 2011
Posts: 2
Hey everybody,

I am trying to build a standalone application that uses hibernate to connect to a postgres database. I have managed to make it work by using hibernate.cfg.xml and hibernate.hbm.xml to map the classes to the tables. But this is not what I really want. I'd rather use the tag mapping, something like this:

Can anybody pretty please tell me what I have to do to make it work the tag way? Or point to a tutorial?

Thank you in advance,

Corneliu
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

When using Annotations, it can be done in two ways...

1.) One by using JPA APIs...
2.) Hibernate Specific APIs...

When using Hibernate Specific APIs and using Annotations, You will have to use "AnnotationConfiguration" class and below links would be helpful:

Step-1 :http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/ch01.html

Step-2 : http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/


SCJP 6 [SCJP - Old is Gold]
Bhavesh Dak
Ranch Hand

Joined: Jun 27, 2009
Posts: 93
Hey corneliu,
I would suggest JAVA PERSISTENCE with HIBERNATE (by Christian Bauer and Gavin King) is a good reference book to strengthen the basics of Hibernate.
Nice examples and clear understanding of the concepts.


SCJP 6(83%), SCWCD 5.0(100%)
corneliu dabija
Greenhorn

Joined: Jun 08, 2011
Posts: 2
@Ram Narayan.M: Thank you, all works fine now.
@Bhavesh Dak: Thank you, I hope I won't have to go any deeper than this with hibernate. But if I do I'll get the book.
@everybody: Someone please kill that fly, it's been annoying the moose for too long.
 
jQuery in Action, 2nd edition
 
subject: hibernate mapping question
 
Similar Threads
An association from the table "dependent" refers to an unmapped class: "Independent"
Hibernate Join Problems
MappingException
Hibernate: confusion how to include seperate attribute in many-to-many mapping file
[SOLVED] This is going to drive me nuts