Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suggestion on Hibernate Package Structure - Best Practice

 
Manju Singh
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Manju Singh
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic