[copying this to the list, as I want to discuss this with everybody]
Ok, I see why you don't want DataContext in the signiture of your method.
This is fine. Then you would need to "bootstrap" a DataContext using
Spring or some other mechanism to a *concrete* implementation of your DAO
framework - something that you were asking for.
The original context still has to be taken from the HttpSession, as
session is a repository of communication state... But we need to make sure
that a session is not passed directly to DAO... Possible solution -
bootstrap DataContext to the request processing thread in the beginning
for request, so that any layer involved could pick it up. Let me see if I
can cook up a sample implementation tonight... I guess we are onto
something here.
Thanks for providing the right example - I guess I just never cared to
write a DAO layer indepdent from the specific persistent API.
Andrus
> A few clarifications... DAO as in the design pattern, or DAO layer:
> http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
>
> One way I could accomplish this (and what I think you are suggesting) is
> to do something w/ a method:
>
> public SomeDataObject getSomeDataById (DataContext dc, int id) <-- bad
>
> Although, if I put this method in an interface and I try to create a
> Hibernate DAO later, it will not be easily pluggable since I am passing
> an implementation specific object (the DataContext) into my Hibernate
> DAO.
>
> My design goal is to basically decouple all details of Cayenne from my
> controller layer (where the HttpSession is). Even passing in an
> HttpSession is not a great idea, since it is mixing the two layers.
>
> The stateless part really isnt as central to the question as it sounded.
> The only reason I would prefer stateless is because it is more scalable
> for web apps.
>
> What Spring accomplished with Hibernate was allowing for a clean
> seperation of the DAO implementation details from the other portions of
> the web application. It is possible to create a HibernateDAO and not
> pass any Hibernate-specific objects in the DAO object method call.
>
> I don't even think the Configuration object should be a problem,
> considering Spring uses an IOC container. (Mere speculation - I haven't
> really researched it).
>
> Scott
>
>
This archive was generated by hypermail 2.0.0 : Mon Jun 28 2004 - 11:46:43 EDT