aspose file tools*
The moose likes Object Relational Mapping and the fly likes how to map POJOs to table in Hibernate without setting the mapping class or mapping resources in Hib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to map POJOs to table in Hibernate without setting the mapping class or mapping resources in Hib" Watch "how to map POJOs to table in Hibernate without setting the mapping class or mapping resources in Hib" New topic
Author

how to map POJOs to table in Hibernate without setting the mapping class or mapping resources in Hib

Ramki Sukumaran
Ranch Hand

Joined: Jun 24, 2013
Posts: 38
Hi,

Can any one tell me how to map POJOs to table in Hibernate without setting the mapping class or mapping resources properties in Hibernate.cfg.xml

While learning hibernate, i was asked to map the POJO classes in the hibernate.cfg.xml. When i run the small application without mapping the POJO classes in the hibernate.cfg.xml file, it throws error saying that

Unknown entity: <entire package>.<POJO clas>

But in big applications, i have seen a Hibernate.cfg.xml file where no POJO classes mapping are there. How does big application working fine without mapping the POJO classses in the configuration file.

Regards
Ramki S
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
You can also use a persistence.xml or annotations on the POJO.
Ramki Sukumaran
Ranch Hand

Joined: Jun 24, 2013
Posts: 38
Hi E Armitage,

Can you please explain me this with an example.

Regards
Ramki S
Ramki Sukumaran
Ranch Hand

Joined: Jun 24, 2013
Posts: 38
How that is done using the persistence.xml. Please any one explain it with an example

Regards
Ramki S
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to map POJOs to table in Hibernate without setting the mapping class or mapping resources in Hib