newbie q #2: how to use value objects?

Michael Harm <[email protected]>
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
Hi again.

I've been using dataobjects with middlegen/ejbdoclet (jboss 3.2.1, 
oracle 9i), but I find that often in my session beans I'd like to be 
able to optionally stick in references to other data objects that have 
an fk relationship to my object.  For instance, if a Person bean has a 
set of related Address beans, I'd like it to not only have the field in 
AddressData for the person pk, but also a PersonData member.  When I 
need to slap that in, I can, (thereby making a 'heavy' dataobject), or 
optionally not (for a 'light' one).

Value objects in xdoclet/ejbdoclet seem the thing to use.  But I'm 
having a hard time integrating the standard middlegen stuff with that.  
ejbdoclet wants @ejb.value-object tags in the comments for cmr  fields 
to create the objects; otherwise I just get the column fields and 
that's no better than what the dataobject guy gives me.  But middlegen 
doesn't seem to want to create these tags for the cmr objects (like, in 
the comments above the generated 'getFooByBarId' things in the entity 
bean). I can make merged files for the column field accessors, but it 
doesn't end up in the object reference accessors like 'getFooByBarId'.  
  I tried hacking the velocity template to stick 'em in there, and told 
the valueobject directive in ejbdoclet to suffix them with "Data" and 
not "Value", and that compiles, but the resultant value objects have 
references to Local beans, not other value objects.  In other words, my 
AddressData guy has members like PersonLocal, not PersonData.  Which 
means I can't use them outside a transaction context, which is the 
whole reason I want to use value/data objects in the first place.

So there's probably something very simple that I'm missing here.

I understand that the whole value object thing is undergoing a major 
refactoring, and there's an effort to replace dataobjects with 
valueobjects entirely.  What's the status of that?  Is there a pointer 
to info about it?  The user mailing list has only a couple references 
to it. Is that the animal I want to be looking at?  Should I check out 
that branch in cvs, or is it still undergoing major development?

Or should I just try my hand at butchering xdoclet's template for data 
objects to make it also include private fields, getters and setters for 
referenced objects (like PersonData in the example above), and call it 
a day?  Pretend that I never heard about value objects, and instead 
have it generate extended data objects?

Thanks for any info!

cheers,

Mike Harm




-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.