It's not a secret anymore!*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Greenhorn

Joined: Jun 24, 2013
Posts: 28
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: 761
    
    9
You can also use a persistence.xml or annotations on the POJO.
Ramki Sukumaran
Greenhorn

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

Can you please explain me this with an example.

Regards
Ramki S
Ramki Sukumaran
Greenhorn

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

Regards
Ramki S
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to map POJOs to table in Hibernate without setting the mapping class or mapping resources in Hib
 
Similar Threads
Configuring Hibernate with two databases
hibernate package problem
Hibernate + Configuration.addClass Exception
hibernate hello world
java.lang.ClassNotFoundException: javax.persistence.JoinTable