What I'm doing with my project, I use VO to get/set attributes in the CMP ejb. I manage to receive an already created VO from the client as parameter in the ejbCreate method. If instead I want to retrieve data, fill in a VO and pass it back to the client, than I create a new instance of the VO in the entity and use it as a return value in a public method defined as @ejb.interface-method.
Here follows a public method of a CMP entity bean which returns an Address VO: /** * @ejb.interface-method * @return */ public AddressValue getAddress() { AddressLocal addrLocal = this.getHomeAddress(); if (addrLocal == null) return null; Long addressId = addrLocal.getAddressId(); String address1 = addrLocal.getAddress1(); String address2 = addrLocal.getAddress2(); String address3 = addrLocal.getAddress3(); String zip = addrLocal.getZip(); String city = addrLocal.getCity(); String country = addrLocal.getCountry(); Date date = addrLocal.getCreationDate(); AddressValue addrValue = new AddressValue(addressId, address1, address2, address3, zip, city, country, date); return addrValue; } getHomeAddress is an abstract getter method which returns an instance of the Address entity bean related with this one in a 1-to-1 relationship. The concept here anyway is that you can have a public method which create a new instance of the VO and returns it to the client (a session bean or an external client). Hope it will help, Marco ----- Original Message ----- From: "Takashi Okamoto" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, August 10, 2003 10:29 AM Subject: [JBoss-user] How can I use VO in CMP? > Hi jboss, > > I found following articles to use Value Object with CMP: > > http://xdoclet.sourceforge.net/valueobjects.html > > I feel it's greate and I immediately tried it with JBoss 3.2.1(+Tomcat > 4.1.24) and JBossIDE 1.2.0. However I user getter/setter for Value > Object(named AddressValue), I got following error message: > > ---------------------------------------------------- > 2003-08-10 06:51:07,746 ERROR [org.jboss.ejb.plugins.LogInterceptor] EJBExcepti > on:^M > javax.ejb.EJBException: Method is not a known CMP field accessor, CMR field acc > essor, or ejbSelect method: methodName=getAddressValue^M > at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invok > e(EntityBridgeInvocationHandler.java:111)^M > at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)^M > at ossbook.eclipse.ejb.AddressBean$Proxy.getAddressValue(<generated>)^M > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)^M > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl > .java:39)^M > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce > ssorImpl.java:25)^M > at java.lang.reflect.Method.invoke(Method.java:324)^M > at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityCont > ainer.java:1044)^M > ---------------------------------------------------- > > I guess method for VO doesn't related field and it cause error. How > can I use VO setter/getter with JBoss? My code is like this: > > /** > * @ejb.bean > * description = "Address Entity Bean" > * name = "Address" > * type = "CMP" > * cmp-version = "2.x" > * view-type = "remote" > * jndi-name = "ejb/address" > * primkey-field = "userid" > * > * @ejb.transaction > * type = "Required" > * > * @ejb.value-object > * name = "Address" > * match = "*" > * > * @ejb.persistence > * table-name = "address" > */ > public abstract class AddressBean implements EntityBean { > > /** @ejb.interface-method */ > public abstract void setAddressValue(AddressValue address); > > /** @ejb.interface-method */ > public abstract AddressValue getAddressValue(); > > // following are general CMP setting...... > /** @ejb.interface-method > * @ejb.pk-field > */ > public abstract String getId(); > > /** @ejb.interface-method */ > public abstract void setId(); > > /** > * @ejb.interface-method > * @ejb.persistence > * ... > */ > public abstract String getParam(); > > /** @ejb.interface-method */ > public abstract void setParam(); > ... > > > regards, > > Takashi Okamoto > > > > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 > _______________________________________________ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user