Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 2
    This is a good idea but for smaller projects it really starts to feel like overkill. This approach also requires a translation layer between the ORM persistence layer and the domain model. Commented Mar 21, 2012 at 11:39
  • @maple_shaft agreed, and that's what I meant by "mapping" :-) Commented Mar 21, 2012 at 11:42
  • @Ozz, the way I've worked is exactly that, the entity classes ARE the domain model (and I might add with quite lots of success). I agree that it ties the domain model to the schema, but that's exactly what I want, as I use convention over configuration, and the nice side effect is that if I see a field on an entity, I don't need to think hard about the name of the table and column where that information is stored. Commented Mar 21, 2012 at 11:54
  • @Augusto I've done it too! and as maple_shaft says, it's fine for small CRUD style apps, but there are many issues as the OP is finding out. One example might be where you have a many to many mapping table eg: StudentClasses, that maps Students to their classes and just contains StudentID and classID, you would not necessarily want to map this in your domain. That's just a quick off the top of my head example. Commented Mar 21, 2012 at 12:07
  • 3
    @Ozz: Your comment seems to contradict the very idea of an ORM. An ORM doesn't "tie your domain directly to your DB schema". The ORM maps your domain to a DB schema, without the need for a separate DAO layer. That's the whole point of an ORM. And most ORMs handle many-to-many mappings just fine, with no domain model needed for the mapping table. Commented Mar 21, 2012 at 16:54