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

Is this Dao?

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm using hibernate and i've the following classes:
domain object:

in order to have persistence code apart, i made:

and finally:

i know i do have to implement proper catching;
now, 2 Qs:
1) is this Dao?
2) is it good to use try catch instead of adding a throws hibernateException?

thanks in advance
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. It looks like DAO to me.

2. I would wrap a custom exception around the HibernateException. This would further enforce the client/service to code to the interface, thus further hiding the fact that you you are using Hibernate as ORM. So if you change to a different ORM, the client code will not change.

For example:
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My mistake forgot the last part ...
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got the idea
thanks a lot!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic