hello everybody,
without success i am now trying for several days to build a
unidirectional many-to-one relation. at this point i am not sure if
the error is caused by my insuffient knowledge about j2ee, by xdoclet
or by jboss.
before going into details: i am using
xdoclet 1.2beta3,
and have tried various combinations of jboss and different databases
including:
jboss 3.08 and 3.2.2rc2, 3.2.rc3(cvs)
HypersonicDB and SapDB
the details, slightly simplified:
there is a PersonBean and a Personen_KlasseBean. Many person may
belong to one Personen_Klasse. The Personen_Klasse does not know which
Persons belong to it.
/**
* @ejb.bean
* name="Person"
* display-name="Person"
* type="CMP"
* view-type="local"
* local-jndi-name="ejb/Person"
* cmp-version="2.x"
* primkey-field="id_String"
*
* @ejb.pk
*
* @ejb.transaction
* type="Required"
*
* @jboss.table-name
* table-name="person"
*
* @jboss.create-table
* create="${create.table}"
*
* @jboss.remove-table
* remove="${remove.table}"
*/
public abstract class PersonBean implements EntityBean {
private static Log log = LogFactory.getLog(PersonBean.class);
/**
* Retrieve the Persons's id.
*
* @return Returns an int representing the id of this Person.
*
* @ejb.interface-method
* view-type="local"
* @ejb.persistence
* table-name="person"
* @jboss.column-name
* name="id_string"
**/
public abstract String getId_String();
public abstract void setId_String(String idString);
/**
* @ejb.interface-method
* view-type="local"
*
* @ejb.persistence
* table-name="person"
* @jboss.column-name
* name="klasse_id"
*
* @ejb.relation
* name="Person-Personen_Klasse"
* role-name="Person-has-a-Personen_Klasse"
* target-ejb="Personen_Klasse"
* target-role-name="Personen_Klasse-has-many-Persons"
* target-multiple="yes"
*
* @jboss.sql-type
* type="INTEGER"
* @jboss.jdbc-type
* type="INTEGER"
*
* @jboss.relation
* fk-column="klasse_id"
* related-pk-field="id"
*/
public abstract Personen_KlasseLocal getPersonen_Klasse();
/**
* @ejb.interface-method
* view-type="local"
*/
public abstract void setPersonen_Klasse(Personen_KlasseLocal personen_Klasse);
/**
* @ejb.create-method
* view-type="local"
*/
public String ejbCreate(String idString)
throws CreateException
{
log.info("first line in create");
setId_String(idString);
log.info("last line in create");
return null;
}
public void ejbPostCreate(String idString)
throws CreateException
{ }
}
at the moment i am not even trying to set the Personen_klasse at
creation but are calling it later, after the PersonBean has been
created.
/**
* @ejb.bean
* name="Personen_Klasse"
* display-name="Personen_Klasse"
* type="CMP"
* view-type="local"
* local-jndi-name="ejb/Personen_Klasse"
* cmp-version="2.x"
* primkey-field="id"
*
* @ejb.pk
*
* @ejb.transaction
* type="Required"
*
* @jboss.table-name
* table-name="personen_klasse"
*
* @jboss.create-table
* create="${create.table}"
*
* @jboss.remove-table
* remove="${remove.table}"
*
*/
public abstract class Personen_KlasseBean implements EntityBean {
/**
* Retrieve the Personen_Klasse's id.
*
* @return Returns an Integer representing the id of this Personen_Klasse.
*
* @ejb.interface-method
* view-type="local"
* @ejb.persistence
* table-name="personen_klasse"
* @jboss.column-name
* name="id"
*/
public abstract Integer getId();
public abstract void setId(Integer id);
/**
* @ejb.create-method
* view-type="local"
*/
public Integer ejbCreate(Integer id) throws CreateException {
setId(id);
return null;
}
public void ejbPostCreate(Integer id) throws CreateException { }
}
when i am now try to excecute the following code:
Personen_KlasseLocal personen_Klasse =
personen_KlasseHome.create(new Integer(nextId++));
PersonLocal person = personHome.create(idString);
person.setPersonen_Klasse(personen_Klasse);
it fails in the 'setPersonen_Klasse' method with the following
message:
Unable to commit, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=knuth//19,
BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable:
(javax.ejb.EJBException: Internal error setting parameters for field personen_Klasse;
CausedByException is:
Cannot convert data ejb/Personen_Klasse:4727 to type INTEGER.)
(the failure in JBoss 3.0.x is different - complaining about dublicated
columns ...)
for completeness, here the table definitions:
CREATE TABLE PERSONEN_KLASSE
(
ID Integer NOT NULL,
KLASSE Varchar (100) ASCII,
PRIMARY KEY (ID)
)
CREATE TABLE PERSON
(
ID_STRING Varchar (10) ASCII NOT NULL,
KLASSE_ID Integer,
CORP_SEC_ID Integer,
VORNAME Varchar (80) ASCII,
NACHNAME Varchar (80) ASCII,
PRIMARY KEY (ID_STRING),
FOREIGN KEY (KLASSE_ID) REFERENCES PERSONEN_KLASSE(ID)
)
unfortunately the code examples from the samples seem not to work
(xdoclet complaints about missing attributes in the ejb.relation tag
and even then it is not working).
does anybody have a working example for this kind of cmr.
tia, heinz-dieter conradi
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user