Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ramki Sukumaran
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use a persistence.xml or annotations on the POJO.
 
Ramki Sukumaran
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi E Armitage,

Can you please explain me this with an example.

Regards
Ramki S
 
Ramki Sukumaran
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How that is done using the persistence.xml. Please any one explain it with an example

Regards
Ramki S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic