The moose likes Object Relational Mapping and the fly likes Suggestion on Hibernate Package Structure - Best Practice Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Suggestion on Hibernate Package Structure - Best Practice" Watch "Suggestion on Hibernate Package Structure - Best Practice" New topic
Author

Suggestion on Hibernate Package Structure - Best Practice

Manju Singh
Greenhorn

Joined: Feb 23, 2005
Posts: 27
I am designing a small leasing application and using Hibernate. But not sure whether EJB or Spring still deciding.

com.process.lease.newbusiness.bo
com.process.lease.newbusiness.persistence.dao
com.process.lease.newbusiness.persistence.hibernate
com.process.lease.newbusiness.persistence.pojo

Is it good practice to keep all POJOs under separate pojos package ? Could someone suggest me good package structure for Hibernate projects like keeping DAO, Hibernate related classes and POJOs under separate packahe.

Also, suggest me for package structure for Spring classes, I am okay with EJB standard.

Thanks
Manju
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

com.process.lease.newbusiness.model
com.process.lease.newbusiness.dao


You usually have a seperate dao and model package for the classes.

POJOs in the model
and Data Access Objects in the dao

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Manju Singh
Greenhorn

Joined: Feb 23, 2005
Posts: 27
How about this package structure.

com.process.lease.newbusiness.model.pojo- all pojos goes unedr this
com.process.lease.newbusiness.model.dao- DAO classes for hibernate persistance logic using Hibernate API
com.process.lease.newbusiness.model.utility- DB Utility/Helper classes

com.process.lease.newbusiness.others......
com.process.lease.newbusiness.others......
com.process.lease.newbusiness.others......

or simply

com.process.lease.newbusiness.model- POJOs
com.process.lease.newbusiness.dao- DAO classes for hibernate persistance logic using Hibernate API
com.process.lease.newbusiness.dao.utility
com.process.lease.newbusiness.others......
com.process.lease.newbusiness.others......
com.process.lease.newbusiness.others......

Thanks
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
Other alternative as per the Hibernate Petstore.

mypetstore.model.dao - DAO Interface expose persistent method
mypetstore.model.dao.hibernate - implementaion of of the DAO Method
mypetstore.model.businessobject - POJO and xyz.hbm.xml (I will prefer to keep mapping file into separate folder)

mypetstore.model.service - Service related stuuf.

For more details Read the article Pet Store

I hope this will help .

Thanks
Rashid
 
 
subject: Suggestion on Hibernate Package Structure - Best Practice
 
Threads others viewed
Getting ClassDefNotFound Exception while using Hibernate3.jar
I am looking for training classes on Spring + Hibernate in Bangalore
package structure during design
Books on spring,Hibernate and JSF
Book For Hibernate and Spring Framework
developer file tools