OK, the DDD approach makes more sense. Having a layer of repository DAO
interfaces that can be implemented by concrete provider classes is a common
way of separating this out, and is much cleaner than having any DAO
functionality on your entities proper. Just thinking off the top of my head,
you could implement this as a manager object, like:

object EntityRepository {
  var engine : EntityDAO = _
}

trait EntityDAO {
  def locateAddress(addr : String) = {...}
  ...
}

class HibernateDAO(sessionFactory : ...) extends EntityDAO {
  ...
}

Then you can set the engine in either your Boot.boot, or in your test setup
hooks based on your needs.

On Tue, Apr 28, 2009 at 2:50 AM, TSP <[email protected]> wrote:

>
> But you don't want the Session in the domain model I thought.
>
> Anyway, after a few hours digging around looking at how other people
> do this stuff with respect to DDD in particular, it looks like I am
> asking the wrong question to a certain extent. The way it is done in
> the DDD site sample app (dddsample.sourceforge.net if you;'re
> interested) is to have repositories - one for each "aggregate" - set
> of linked classes (typical example is an order which aggregates order
> lines and possibily delivery history). The repositories are
> implemented as interfaces and have persistence neutral finders "get
> all outstanding orders with credit-stopped customers" for example.
> This is part of the domain model, but returns typical jpa/hibernate
> persisted objects. The implementation of the repository is hibernate
> aware and uses getCurrentSession() quite freely. The implementation is
> injected via spring.
>
> Back in my context, this means I want my repository impls to be EM or
> session aware too - so my original question stands - but the
> repository mechanism separates the domain model from the direct
> persistence layer which should allay your concerns.
>
> Tim
>
> On Apr 28, 6:48 am, Viktor Klang <[email protected]> wrote:
> > Also, if you use Hibernate, you can use:
> >
> > *Session.createFilter*(city.getAddresses(), "where this.name like
> > 'S%'").list();
> >
> > On Tue, Apr 28, 2009 at 5:31 AM, Derek Chen-Becker <
> [email protected]>wrote:
> >
> >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to