Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / April 2004

Tip: Looking for answers? Try searching our database.

Problems with XDoclet and Value Object generation for CMR relationships

Thread view: 
Kenneth Aitken - 28 Jan 2004 15:51 GMT
I would appreciate help/feedback, because this is affecting our ability
to create useful code on the EJB session beans to call EJB entity beans.

I am running XDoclet Version 1.2 Beta 3. I will use an example of a 1:1
relationship, because it is much less complicated.
I am creating the necessary xxxCMP and xxxValue files using the
ejb.value-object tag, such as this in a CustomerBean:
   /**
   * @ejb.interface-method
   * view-type="local"
   * @ejb.relation
   * name="Customer-Address"
   * role-name="customer-has-address"
   * relation-name="customer-has-address"
   * target-ejb="Address"
   * target-role-name="address-belongs-to-customer"
   * target-multiple = "no"
   * target-cascade-delete = "yes"
   * @jboss.relation
   * fk-column = "customeraddress"
   * related-pk-field = "addressID"
   * @jboss.relation-mapping
   * style = "foreign-key"
   * @ejb.value-object
   * compose="com.foobar.value.AddressValue"
   * compose-name="AddressValue"
   * members="com.foobar.interfaces.AddressLocal"
   * members-name="Address"
   * relation="external"
   * match="*"
   */
   public abstract AddressLocal getAddress();
   /**
   * @ejb.interface-method
   * view-type="local"
   */
   public abstract void setAddress(AddressLocal address);

The problem is that it generates CMP code that either allows EJB Entity
Bean relationships to be set (when aggregate and aggregate-name are
used) or Entity Bean values to be set (when compose and compose-name are
used), but why only one without the other?

Moreover, why does the generated CMP code not allow for creation of new
entities, such as when the ID-field has not been set? This contradicts
the documentation on XDoclet's website: "This means that the generated
accessor methods for this relationship will create and remove Address
entities when adding and removing them via the generated addAddress()
and removeAddress() methods."
http://xdoclet.sourceforge.net/valueobjects.html

Here the CustomerCMP file would look like this, where the Address object
is set using the AddressValue object, but the relationship between
Customer and Address is not set (i.e. compose and compose-name have been
used):
public void setCustomerValue( com.foobar.CustomerValue valueHolder )
{
   try
   {
      //Set Customer members from values

      // Anonymous block to allow variable declations without conflicts
      {
         // Checks for null composition
         if (valueHolder.getAddressValue() != null)
         {
            java.lang.String pk =
               valueHolder.getAddressValue().getAddressID();
            com.foobar.interfaces.AddressLocalHome home =
               com.foobar.util.AddressUtil.getLocalHome();
            com.foobar.interfaces.AddressLocal relation =
               home.findByPrimaryKey(pk);
            relation.setAddressValue(valueHolder.getAddressValue());
         }
      }
   }
   catch (Exception e)
   {
      throw new javax.ejb.EJBException(e);
   }
}
SGM - 08 Apr 2004 19:36 GMT
Hi,

Did you ever figure out how to get around this problem? I am facing the
same issue and am kinda stuck.

Thanks in advance.
-SG
SGM - 08 Apr 2004 19:37 GMT
Hi,

Did you ever figure out how to get around this problem? I am facing the
same issue and am kinda stuck.

Thanks in advance.
-SG


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.