Re: DAO with EOF
James Brook <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
On 14 Nov 2007, at 18:24, Daryl Thachuk wrote: > > On 13-Nov-07, at 5:11 AM, Anders Peterson wrote: > >> Hi, >> >> I'd like to make my business objects independent of EOF. Thinking >> about doing doing this using the Data Access Object design pattern >> where the EOs are the DAOs and the BOs are POJOs. >> >> http://java.sun.com/blueprints/corej2eepatterns/Patterns/ >> DataAccessObject.html >> >> Is (something like) this commonly done? Has anyone done it? >> >> /Anders >> > > Why would you want to do this? I think this pattern exists because > of limitations in J2EE. Limitations which do not exist in EOF. > > Of course I could be wrong :-) > > -daryl We did it for an integration with the Rome library. Rome consumes common syndication format like RSS and Atom and builds an idealised object graph of POJOs. We wanted to add persistence and a WebObjects API, so we copied the POJOs to EOs. The Rome classes implement an interface called CopyFrom. In our implementation a method on the top level 'feed' EO in the object graph copies the object graph from the POJOs to the EOs using reflection. Everything performs okay, but the solution doesn't feel very clean. It was really just because we wanted to use EOF for persistence and later for working with objects that we fetched into other applications, but we could not map POJOs directly to the database with EOF, because that's simply not the way it works. I think to have your business objects independent of EOF you are looking for something that uses the DataMapper pattern (http://martinfowler.com/ eaaCatalog/dataMapper.html), but then maybe you should choose between using EOF, or using POJOs and some other persistence mechanism. -- James _______________________________________________ WebObjects-dev mailing list [email protected] http://www.omnigroup.com/mailman/listinfo/webobjects-dev