Support Requests item #538800, was opened at 2002-04-03 17:23
Message generated for change (Settings changed) made by stevensa
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402705&aid=538800&group_id=31602

Category: None
Group: None
>Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: @weblogic:target-column-map not working

Initial Comment:
Hi,

while the tag 
         * @weblogic:column-map
         *    foreign-key-column="STOCK_ID"
         *    key-column="ID"
works OK,adding the tag 
         * @weblogic:target-column-map
         *    foreign-key-column="STOCK_ID"
         *    key-column="ID"
does not seem to change anything in the produced 
weblogic-cmp-rdbms-jar-xml.

I have to add a useless relation side although I need 
only a one directional relation.

any ideas?

thanks.

----------------------------------------------------------------------

Comment By: Aslak Hellesøy (rinkrank)
Date: 2002-04-09 02:43

Message:
Logged In: YES 
user_id=49846

Try this:

 * @ejb:relation
 *    name="StockEntity-itemInfo"
 *    role-name="PortfolioItem-Stock"
 *    target-ejb="StockEntity"
 *    target-multiple="yes"
 *    target-role-name="Stock-PortfolioItem"
 * @weblogic:target-column-map
 *    foreign-key-column="STOCK_ID"
 *    key-column="ID"

And see if it helps. The docs for @ejb:relation might be a 
bit unclear about this, but they _do_ suggest that you need 
to specify target-multiple and target-role-name for 
unidirectional relationships.

You didn't tell me what XDoclet version you're using. I 
therefore assume that you have tried the latest CVS 
version. I strongly encourage you to try out Middlegen 
(http://boss.bekk.no/boss/middlegen/). It's well tested 
with WLS.

P.S. Next time you attach big stuff, please use the attach 
feature at the bottom of the tracker page, and don't post a 
bug report unless you're really sure it's a bug. Mailing 
list is better for plain support like this ;-) D.S.

/Aslak

----------------------------------------------------------------------

Comment By: Ozgur Tumer (ozgurt)
Date: 2002-04-08 15:11

Message:
Logged In: YES 
user_id=509274

The StockEntityBean did not go on properly...

package com.objectlearn.portfoliomanagement.ejbs.stock;

import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;

import 
com.objectlearn.portfoliomanagement.ejbs.portfolioitem.Portf
olioItemEntity;
import com.objectlearn.portfoliomanagement.model.Stock;

/**
 * @author <a href="mailto:[EMAIL PROTECTED]
esolutions.com">Ozgur Tumer</a>
 *
 * @ejb:bean
 *    type="CMP"
 *    cmp-version="2.x"
 *    name="StockEntity"
 *    jndi-name="StockEntityHome"
 *    local-jndi-name="StockEntityLocalHome"
 *    view-type="remote"
 *    primkey-field="id"
 *
 * @ejb:finder
 *    signature="java.util.Collection findAll()"
 *    unchecked="true"
 *    query="SELECT DISTINCT OBJECT(c) FROM StockEntity c 
WHERE c.id IS NOT NULL"
 *    result-type-mapping="Local"
 * 
 * @ejb:finder
 *    signature="StockEntity findByAlias(java.lang.String 
alias)"
 *    unchecked="true"
 *    query="SELECT OBJECT(s) FROM StockEntity AS s WHERE 
s.alias = ?1 "
 *    result-type-mapping="Local"
 *  
 * @ejb:pk
 *        class="java.lang.Integer"
 *
 * @ejb:transaction type="Required"
 * 
 * @weblogic:data-source-name PortfolioManagementDataSource
 * @weblogic:table-name STOCKS
 * @weblogic:persistence
 *
 */
public abstract class StockEntityBean implements EntityBean 
{

        /**
         * @ejb:create-method view-type="remote"
         */
        public Integer ejbCreate(Stock stock){
                setAlias(stock.getAlias());
                setName(stock.getName());
                setUrl(stock.getUrl());
                setIcon(stock.getIcon());
                return null;
        }

        public void ejbPostCreate(Stock stock){
        }

   /**
    * @ejb:interface-method view-type="remote"
    */
        public void setStock(Stock stock){
                setAlias(stock.getAlias());
                setName(stock.getName());
                setUrl(stock.getUrl());
                setIcon(stock.getIcon());
        }

   /**
    * @ejb:interface-method view-type="remote"
    */
        public Stock getStock(){
                Stock stock = new Stock(getAlias(), getName
(), getUrl(), getIcon());
                return stock;
        }

   /**
    * @param id id of this StockEntity
    */
   public abstract void setId(Integer id);

   /**
    * @return id of this StockEntity
    *
    * @ejb:persistent-field
    * @ejb:pk-field
    *
    * @weblogic:dbms-column ID
    */
   public abstract Integer getId();



   /**
    * @param name name of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    */
   public abstract void setName(java.lang.String name);

   /**
    * @return name of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    * @ejb:persistent-field
    *
    * @weblogic:dbms-column NAME
    */
   public abstract java.lang.String getName();

   /**
    * @param alias alias of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    */
   public abstract void setAlias(java.lang.String alias);

   /**
    * @return alias of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    * @ejb:persistent-field
    *
    * @weblogic:dbms-column ALIAS
    */
   public abstract java.lang.String getAlias();

   /**
    * @param url url of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    */
   public abstract void setUrl(java.lang.String url);

   /**
    * @return url of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    * @ejb:persistent-field
    *
    * @weblogic:dbms-column URL
    */
   public abstract java.lang.String getUrl();

   /**
    * @param icon icon of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    */
   public abstract void setIcon(java.lang.String icon);

   /**
    * @return icon of this StockEntity
    *
    * @ejb:interface-method view-type="remote"
    * @ejb:persistent-field
    *
    * @weblogic:dbms-column ICON
    */
   public abstract java.lang.String getIcon();
      

}


the DDL;



CREATE TABLE "EUSER"."CUSTOMER"("ID" NUMBER(19) 
NOT 
NULL, "NAME" VARCHAR2(20) NOT NULL, "ALIAS" VARCHAR2(20) 
NOT NULL TABLESPACE "USERS" 


CREATE UNIQUE INDEX "EUSER"."IND" 
ON "EUSER"."CUSTOMER"("ALIAS")


CREATE TABLE "EUSER"."PORTFOLIO_ITEMS"("ID" 
NUMBER(19) NOT 
NULL, "CUSTOMER_ID" NUMBER(19) NOT NULL, "STOCK_ID" NUMBER
(9) NOT NULL, "BUY_VALUE" NUMBER(20, 2) NOT 
NULL, "BUY_DATE" DATE NOT NULL, "QUANTITY" NUMBER(8) NOT 
NULL) 


CREATE TABLE "EUSER"."STOCKS"("ALIAS" VARCHAR2(5) 
NOT 
NULL, "NAME" VARCHAR2(30) NOT NULL, "ID" NUMBER(9) NOT 
NULL, "ICON" VARCHAR2(10) NOT NULL, "URL" VARCHAR2(30) NOT 
NULL) 

----------------------------------------------------------------------

Comment By: Ozgur Tumer (ozgurt)
Date: 2002-04-08 15:05

Message:
Logged In: YES 
user_id=509274

The whole code:

package 
com.objectlearn.portfoliomanagement.ejbs.portfolioitem;

import java.rmi.RemoteException;
import java.sql.Date;

import javax.ejb.*;
import javax.naming.*;

import com.objectlearn.portfoliomanagement.ejbs.stock.*;
import com.objectlearn.portfoliomanagement.model.*;

/**
 * @author <a href="mailto:[EMAIL PROTECTED]
esolutions.com">Ozgur Tumer</a>
 *
 * @ejb:bean
 *    type="CMP"
 *    cmp-version="2.x"
 *    name="PortfolioItemEntity"
 *    jndi-name="PortfolioItemEntityHome"
 *    local-jndi-name="PortfolioItemEntityHome"
 *    view-type="remote"
 *    primkey-field="id"
 * 
 *    @ejb:transaction type="Required"
 *
 * @ejb:finder
 *    signature="java.util.Collection findAll()"
 *    unchecked="true"
 *    query="SELECT DISTINCT OBJECT(p) FROM 
PortfolioItemEntity p WHERE p.id IS NOT NULL"
 *    result-type-mapping="Local"

 * @ejb:pk
 *        class="java.lang.Long"
 * 
 * @ejb:ejb-ref
 *    ejb-name="StockEntity"
 * 
 * @weblogic:data-source-name PortfolioManagementDataSource
 * @weblogic:table-name PORTFOLIO_ITEMS
 * @weblogic:persistence
 *
 */
public abstract class PortfolioItemEntityBean implements 
EntityBean {

        /**
         * @ejb:create-method view-type="home"
         */
        public Long ejbCreate(PortfolioItem item) {
                setDate(new Date(item.getQuote().getDate
().getTime()));
                setQuantity(item.getQuantity());
                setValue(item.getQuote().getValue());
                return null;
        }

        public void ejbPostCreate(PortfolioItem item) {
                try {
                        Stock stock = item.getQuote
().getStock();
                        Context jndiContext = new 
InitialContext();
                        StockEntityHome stockEntityHome = 
(StockEntityHome) jndiContext.lookup("ejb/StockEntity");
                        StockEntity stockEntity = 
stockEntityHome.findByAlias(stock.getAlias());
                        setStockEntity(stockEntity);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }

        /**
         * @ejb:interface-method view-type="remote"
         */
        public PortfolioItem getPortfolioItem() throws 
RemoteException {
                Stock stock = getStockEntity().getStock();
                Quote quote = new Quote(stock, getValue());
                PortfolioItem item = new PortfolioItem
(quote, getQuantity());
                return item;
                }

        /**
         * @ejb:interface-method view-type="remote"
         */
        public void setPortfolioItem(PortfolioItem item) 
throws RemoteException {
                setDate(new Date(item.getQuote().getDate
().getTime()));
                setQuantity(item.getQuantity());
                setValue(item.getQuote().getValue());
                try {
                        Stock stock = item.getQuote
().getStock();
                        Context jndiContext = new 
InitialContext();
                        StockEntityHome stockEntityHome = 
(StockEntityHome) jndiContext.lookup("ejb/StockEntity");
                        StockEntity stockEntity = 
stockEntityHome.findByAlias(stock.getAlias());
                        setStockEntity(stockEntity);
                } catch (Exception e) {
                        e.printStackTrace();
                }
                
        }


        /**
         * @param id id of this portfolio
         */
        public abstract void setId(Long id);

        /**
         * @return id of this portfolio
         *
         * @ejb:persistent-field
         * @ejb:pk-field
         *
         * @weblogic:dbms-column ID
         */
        public abstract Long getId();

        /**
         * @param stockId id of this portfolio
         */
        public abstract void setStockId(Integer id);

        /**
         * @return stockId  of this portfolio
         *
         * @ejb:persistent-field
         * @ejb:pk-field
         *
         * @weblogic:dbms-column STOCK_ID
         * 
         */
        public abstract Integer getStockId();

        /**
         * @param customer_id id of this portfolio
         */
        public abstract void setCustomerId(Long id);

        /**
         * @return id of this portfolio
         *
         * @ejb:persistent-field
         *
         * @weblogic:dbms-column CUSTOMER_ID
         */
        public abstract Long getCustomerId();

/**
 * @param StockEntity StockEntity of this item
 *
 * @ejb:interface-method view-type="remote"
 */
public abstract void setStockEntity
(com.objectlearn.portfoliomanagement.ejbs.stock.StockEntity 
stockEntity);

/**
 * @return StockEntity StockEntity of this item
 *
 * @ejb:interface-method view-type="remote"
 * @ejb:relation
 *    name="StockEntity-itemInfo"
 *    role-name="PortfolioItem-Stock"
 *    target-ejb="StockEntity"
 * @weblogic:target-column-map
 *    foreign-key-column="STOCK_ID"
 *    key-column="ID"
 */
public abstract 
com.objectlearn.portfoliomanagement.ejbs.stock.StockEntity 
getStockEntity();

        /**
         * @param quantity quantity of the item
         *
         * @ejb:interface-method view-type="remote"
         */
        public abstract void setQuantity(int quantity);

        /**
         * @return quantity of the item
         *
         * @ejb:interface-method view-type="remote"
         * @ejb:persistent-field
         *
         * @weblogic:dbms-column QUANTITY
         */
        public abstract int getQuantity();

        /**
         * @param date date bought of the item
         *
         * @ejb:interface-method view-type="remote"
         */
        public abstract void setDate(java.sql.Date date);

        /**
         * @return date bought of the item
         *
         * @ejb:interface-method view-type="remote"
         * @ejb:persistent-field
         *
         * @weblogic:dbms-column BUY_DATE
         */
        public abstract java.sql.Date getDate();

        /**
         * @param value value bought of the item
         *
         * @ejb:interface-method view-type="remote"
         */
        public abstract void setValue(double value);

        /**
         * @return value bought of the item
         *
         * @ejb:interface-method view-type="remote"
         * @ejb:persistent-field
         *
         * @weblogic:dbms-column BUY_VALUE
         */
        public abstract double getValue();

}




package com.objectlearn.portfoliomanagement.ejbs.stock;

import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;

import 
com.objectlearn.portfoliomanagement.ejbs.portfolioitem.Portf
olioItemEntity;
import com.objectlearn.portfoliomanagement.model.Stock%

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-04-08 14:49

Message:
Logged In: NO 

Hi,

What I am trying to do is a single sided 1 to many relation-
ship. Which is 

1 PortfolioItemEntity - > has 1 StockItemEntity

Where ofcourse 1 StrockEntity can belong to many 
PortfolioItemEntity but I am not interested with that side 
of the relation. 

So What I do is I define a getter and a setter in the 
PortfolioItemEntity:

/**
 * @param StockEntity StockEntity of this item
 *
 * @ejb:interface-method view-type="remote"
 */
public abstract void setStockEntity
(com.objectlearn.portfoliomanagement.ejbs.stock.StockEntity 
stockEntity);

/**
 * @return StockEntity StockEntity of this item
 *
 * @ejb:interface-method view-type="remote"
 * @ejb:relation
 *    name="StockEntity-itemInfo"
 *    role-name="PortfolioItem-Stock"
 *    target-ejb="StockEntity"
 * @weblogic:target-column-map
 *    foreign-key-column="STOCK_ID"
 *    key-column="ID"
 */
public abstract 
com.objectlearn.portfoliomanagement.ejbs.stock.StockEntity 
getStockEntity();

And that is all I want to have. 

the DDL is like:

CREATE TABLE "EUSER"."PORTFOLIO_ITEMS"("ID" 
NUMBER(19) NOT 
NULL, "CUSTOMER_ID" NUMBER(19) NOT NULL, "STOCK_ID" NUMBER
(9) NOT NULL, "BUY_VALUE" NUMBER(20, 2) NOT 
NULL, "BUY_DATE" DATE NOT NULL, "QUANTITY" NUMBER(8) NOT 
NULL) 


CREATE TABLE "EUSER"."STOCKS"("ALIAS" VARCHAR2(5) 
NOT 
NULL, "NAME" VARCHAR2(30) NOT NULL, "ID" NUMBER(9) NOT 
NULL, "ICON" VARCHAR2(10) NOT NULL, "URL" VARCHAR2(30) NOT 
NULL) 

where PORTFOLIO_ITEMS table has an STOCK_ID which should 
match the ID in the STOCKS table.

The definition   @weblogic:target-column-map does not 
produce any code in the 


I will try to send the whole code as well.

By the way sorry for the late reply, I was giving a course 
and in fact did not expect you guys to be this prompt.

thanks.


----------------------------------------------------------------------

Comment By: Aslak Hellesøy (rinkrank)
Date: 2002-04-04 00:34

Message:
Logged In: YES 
user_id=49846

Can you post the source of the two beans that participate 
in the relation?
Please include the ddl for the involved tables too.

It's not clear to me what cardinality and directionality 
you're trying to achieve for your relation.

Aslak

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402705&aid=538800&group_id=31602


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to