0

I'm implementing data access logic in a Java application using Hibernate and I'm a little confused about this issue. AFAIK one of the main advantages to use ORM systems is to work with attached object, but using DAO approach leads to have (in many application contexts) detached entities.

I read several posts about this issue (this for example), but I can't understand if there is a correct apporach to follow, or if the choice is left to developer. Can you help me?

davioooh
  • 23,742
  • 39
  • 159
  • 250
  • possible duplicate of [I found JPA, or alike, don't encourage DAO pattern](http://stackoverflow.com/questions/2100115/i-found-jpa-or-alike-dont-encourage-dao-pattern) – Luiggi Mendoza Oct 18 '13 at 15:50
  • well the ORM is basically a DAO so... you're already using it. And no, ORM entities are not business entities. – MikeSW Oct 19 '13 at 15:51

1 Answers1

0

Why do you think that not using DAOs is going to alleviate your detached objects scenarios? I don't think it will. If you want to use ORM, you simply need to re-attach objects sometimes.

In the answer to a related question, I argue that you really should use DAOs.

Community
  • 1
  • 1
hvgotcodes
  • 118,147
  • 33
  • 203
  • 236
  • What I actually mean is: I'd like to create an abstraction level for data access using DAO, but using this approach can lead me to losing some of the ORM advantages. It's my worry real or just a newbe paranoia? :) – davioooh Oct 18 '13 at 15:58
  • From Java EE 6, if we use the DAO design pattern, in fact, add more complexity, and of course, more code. – Paul Vargas Oct 18 '13 at 16:03