Inline... PS: Moved the discussion to xdoclet-user 'cause I think other users are interested in this discussion too.
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:xdoclet-devel- > [EMAIL PROTECTED]] On Behalf Of Andrew Stevens > Sent: Friday, February 22, 2002 4:12 PM > To: [EMAIL PROTECTED] > Subject: [Xdoclet-devel] DAOs > > Any opinions on the best way to handle EJB lifecycle events through DAOs? > I've got two main choices, and I'm not sure which way to jump: > > a) use DataObjects to pass around the state values between the bean and > the > DAO > or > b) pass a reference to the bean to the DAO. > > e.g. ejbLoad would either call dao.load(pk) which return a dataobject, and > I > then set the fields to the dataobject's values, or it calls dao.load(pk, > this) and the DAO sets the fields itself. > > The drawback to the first approach is that you must be using/generating > the > DataObject (or a DataObject containing all the persistent fields, once the > fine-grained value object stuff is done), which may not be the case. > > The drawback I anticipated with the second approach isn't actually a > problem > at the moment, but basically I had expected that it would require having > getters (for the store method) and setters (for the load method) for every > persistent field (which isn't currently the case in some of my EJBs that > have read-only fields). This was because I assumed the actual fields in > the > BMP subclass would be private (or at least wouldn't be public), so I > wouldn't be able to change them directly. However, looking at > entity-cmp11.j, I see that they're currently declared as public. > > So, 2 questions: > 1) Do the fields need to be public, or should they be changed to private? > Does 1.1 CMP require them to be public, or does it use the > getters/setters? CMP 1.1 requires them to be public, CMP2 requires them to have abstract getter/setters. > If it does need them public, should we use separate code for BMP that > declares them private instead? No, you can but follow the excellent pattern Rickard defined for smooth migration to ejb2. Declare all your fields with abstract getter/setters, let entitycmp/bmp handle the difference between ejb1.1/2 for you. Use that for both bmp and cmp. You'll be able to migrate from one to the other easily. > 2) Which way is better for the DAOs? Dataobjects or references to the > bean? > (and does it depend on the answer to 1?) Reference to the bean. I don't find anything wrong with passing this instead of getEJBObject() for this case because DAO is considered a friend of the BMP bean. Will it cause problems? Ara. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
