Hi,
we have a Bean ContractCompany that has a PrimaryKeyClass (generated by
XDoclet) with two fields: Long contractNo and Long companyId. When we also
try to generate a value object for this Bean it only passes one of the
fields as a parameter to the PK constructor when constructing a new
ContractCompanyPK in the VO constructor:
private middlegen.demo.ejb.ContractCompanyPK pk;
public ContractCompanyValue( java.lang.Long companyId,java.lang.Long
contractNo )
{
this.companyId = companyId;
companyIdHasBeenSet = true;
this.contractNo = contractNo;
contractNoHasBeenSet = true;
pk = new middlegen.demo.ejb.ContractCompanyPK(this.getContractNo());
}
The constructor in ContractCompanyPK looks like this:
public ContractCompanyPK( java.lang.Long companyId,java.lang.Long
contractNo )
{
this.companyId = companyId;
this.contractNo = contractNo;
}
This, of course gives errors when building. The same problem occurs in the
other ContractCompanyValue constructors and in the CMP classes of beans that
have a relation to ContractCompany. e.g. CompanyBean:
public void addContractCompany(middlegen.demo.ejb.ContractCompanyValue
added)
throws javax.ejb.CreateException
{
try
{
middlegen.demo.ejb.ContractCompanyPK pk = new
middlegen.demo.ejb.ContractCompanyPK(added.getContractNo());
middlegen.demo.ejb.ContractCompanyLocalHome home =
middlegen.demo.ejb.ContractCompanyUtil.getLocalHome();
middlegen.demo.ejb.ContractCompanyLocal relation =
home.findByPrimaryKey(pk);
getContractCompanies().add(relation);
}
catch (Exception e){
if (e instanceof javax.ejb.CreateException)
throw (javax.ejb.CreateException)e;
else
throw new javax.ejb.EJBException(e);
}
}
As XDoclet generates a correct primary key class from the
ContractCompanyBean, the tags seem to be correct, but you never know, so
here it is(It's mostly generated by middlegen, but we added the value object
parts):
package middlegen.demo.ejb;
/**
* @author <a href="http://boss.bekk.no/boss/middlegen/">Middlegen</a>
*
* @ejb:bean
* type="CMP"
* cmp-version="2.x"
* name="ContractCompany"
* local-jndi-name="middlegen.demo.ejb.ContractCompanyLocal"
* view-type="local"
*
* @ejb:data-object
* container="true"
* setdata="true"
*
* @ejb:value-object
* name="ContractCompany"
* match="*"
* instantiation="eager"
*
* @ejb:finder
* signature="java.util.Collection
findByCompany(middlegen.demo.ejb.CompanyLocal company)"
* result-type-mapping="Local"
* method-intf="LocalHome"
* query="SELECT DISTINCT OBJECT(o) FROM ContractCompany o WHERE
o.company = ?1"
*
* @ejb:finder
* signature="java.util.Collection
findByContract(middlegen.demo.ejb.ContractLocal contract)"
* result-type-mapping="Local"
* method-intf="LocalHome"
* query="SELECT DISTINCT OBJECT(o) FROM ContractCompany o WHERE
o.contract = ?1"
*
*
* @weblogic:table-name CONTRACT_COMPANY
* @weblogic:data-source-name jdbc/TRIM
* @weblogic:persistence
*
* @jboss:table-name CONTRACT_COMPANY
*
* @orion:bean data-source="middlegen.database"
*/
public abstract class ContractCompanyBean implements javax.ejb.EntityBean {
/**
* Context set by container
*/
private javax.ejb.EntityContext _entityContext;
/**
* Returns the companyId
*
* @return the companyId
*
* @ejb:persistent-field
* @ejb:interface-method view-type="local"
* @ejb:pk-field
*
* @weblogic:dbms-column COMPANY_ID
*
* @jboss:column-name COMPANY_ID
*/
public abstract java.lang.Long getCompanyId();
/**
* Sets the companyId
*
* @param companyId the new companyId
*/
public abstract void setCompanyId(java.lang.Long companyId);
/**
* Returns the contractNo
*
* @return the contractNo
*
* @ejb:persistent-field
* @ejb:interface-method view-type="local"
* @ejb:pk-field
*
* @weblogic:dbms-column CONTRACT_NO
*
* @jboss:column-name CONTRACT_NO
*/
public abstract java.lang.Long getContractNo();
/**
* Sets the contractNo
*
* @param contractNo the new contractNo
*/
public abstract void setContractNo(java.lang.Long contractNo);
/**
* Returns a collection of local Company
*
* @return a collection of local Company
*
* @ejb:interface-method view-type="local"
*
* @ejb:relation
* name="company-contract_company"
* role-name="contract_company-has-company"
*
*
* @weblogic:target-column-map
* foreign-key-column="COMPANY_ID"
* key-column="COMPANY_ID"
*
* @ejb:value-object
* match="*"
* aggregate="middlegen.demo.ejb.CompanyValue"
* aggregate-name="CompanyValue"
*
*/
public abstract middlegen.demo.ejb.CompanyLocal getCompany();
/**
* Sets a collection of local Company
*
* @ejb:interface-method view-type="local"
*
* @param company a collection of local Company
*/
public abstract void setCompany(middlegen.demo.ejb.CompanyLocal company);
/**
* Returns a collection of local Contract
*
* @return a collection of local Contract
*
* @ejb:interface-method view-type="local"
*
* @ejb:relation
* name="contract-contract_company"
* role-name="contract_company-has-contract"
*
*
* @weblogic:target-column-map
* foreign-key-column="CONTRACT_NO"
* key-column="CONTRACT_NO"
*
* @ejb:value-object
* match="*"
* aggregate="middlegen.demo.ejb.ContractValue"
* aggregate-name="ContractValue"
*
*/
public abstract middlegen.demo.ejb.ContractLocal getContract();
/**
* Sets a collection of local Contract
*
* @ejb:interface-method view-type="local"
*
* @param contract a collection of local Contract
*/
public abstract void setContract(middlegen.demo.ejb.ContractLocal
contract);
/**
* Gets a data object representing this instance
*
* @return a data object representing this instance
*
* @ejb:interface-method view-type="local"
*/
public abstract middlegen.demo.ejb.ContractCompanyData getData();
/**
* Sets a data object representing this instance
*
* @param data a data object holding new values
*
* @ejb:interface-method view-type="local"
*/
public abstract void setData(middlegen.demo.ejb.ContractCompanyData
data);
/**
* @ejb:interface-method view-type="local"
*/
public abstract ContractCompanyValue getContractCompanyValue();
/**
* @ejb:interface-method view-type="local"
*/
public abstract void setContractCompanyValue(ContractCompanyValue value);
.
.
.
.
ejbCreate() and other ejb methods
}
Hope someone can help.
This is originally using an XDoclet version included with middlegen
BEFORE_CLASSTYPE_REFACTORING form CVS on 18.04, but we've tried newer
xdoclet versions from cvs with the same result.
Thanks,
Lisa and Freddy.
_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user