Hi,
I need to extract the PK from a Data object. I've written a template (ie .j ) snippet
to generate a method of the form ...
// method to extract the PK from a Data object.
public CustomerPK getPKFrom(CustomerData data) {
CustomerPK pk = new CustomerPK();
pk.setCustomerIdf(data.getCustomerId());
...
return pk;
}
I've put it in the util.j template, although I was split whether it should
be in the Data object. If you want to include it a patch is attached. I'll
leave it to you to decide where it should 'really' go.
--
regards
Neale Swinnerton
Index: util.j
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/resources/xdoclet/ejb/util.j,v
retrieving revision 1.4
diff -u -w -u -r1.4 util.j
--- util.j 2001/10/26 20:49:43 1.4
+++ util.j 2001/11/29 16:46:28
@@ -60,4 +60,13 @@
return localHome;
}
</XDtEjbIntf:ifLocalEjb>
+
+ // method to extract the PK from a Data object.
+ public <XDtClass:classOf><XDtEjbPk:pkClass/></XDtClass:classOf>
+getPKFrom(<XDtEjbDataObj:dataObjectClass/> data) {
+ <XDtClass:classOf><XDtEjbPk:pkClass/></XDtClass:classOf> pk = new
+<XDtClass:classOf><XDtEjbPk:pkClass/></XDtClass:classOf>();
+ <XDtEjbPersistent:forAllPersistentFields only-pk="true">
+ pk.<XDtMethod:setterMethod/>(data.<XDtMethod:getterMethod/>());
+ </XDtEjbPersistent:forAllPersistentFields>
+ return pk;
+ }
}