[jboss-user] [JBoss Eclipse IDE (users)] - XDoclet shortcoming?

scramer do-not-reply at jboss.com
Fri Dec 22 09:01:15 EST 2006


Hello and merry christmas to everybody.

I'm using JBossIDE 2.0.0beta2.
The problem I am facing is with relations and the unknown-pk feature. I have two CMP EJBs:


  | package de.chitec.physio.server.ejb;
  | 
  | import java.rmi.RemoteException;
  | import java.util.Date;
  | 
  | import javax.ejb.EJBException;
  | import javax.ejb.EntityBean;
  | import javax.ejb.EntityContext;
  | import javax.ejb.RemoveException;
  | 
  | import org.apache.log4j.Logger;
  | 
  | /**
  |  * @ejb.bean 
  |  *  name="CMPPerson" 
  |  *  display-name="CMPPerson" 
  |  *  description="Description for CMPPerson"
  |  *  jndi-name="ejb/CMPPerson" 
  |  *  type="CMP" 
  |  *  cmp-version="2.x" 
  |  *  view-type="local" 
  |  *  reentrant = "false"
  |  *  local-jndi-name = "ejb/CMPPerson"
  |  *  
  |  * @ejb.persistence 
  |  *  table-name = "person"
  |  * 
  |  * @ejb.pk
  |  *   class="java.lang.Object"
  |  *   
  |  * @ejb.finder
  |  *   signature="java.util.Collection findByLastName(java.lang.String pLastName)"
  |  *   query="SELECT Object(o) FROM CMPPerson o WHERE o.lastName LIKE ?1"
  |  *  
  |  * @jboss.entity-command 
  |  *  name = "${jboss.entity.command}" 
  |  *  class = "${jboss.entity.class}"
  |  *  
  |  * @jboss.unknown-pk 
  |  *  class="java.lang.Integer" 
  |  *  column-name="id" 
  |  *  jdbc-type="INTEGER" 
  |  *  sql-type="INTEGER"
  |  *  auto-increment="true"
  |  *  
  |  * @jboss.persistence 
  |  *  pk-constraint = "true" 
  |  *  table-name = "person"
  |  *  
  |  */
  | public abstract class CMPPersonBean implements EntityBean
  | {
  | 
  | 	public CMPPersonBean()
  | 	{
  | 	}
  | 
  | 	public void ejbActivate() throws EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	public void ejbLoad() throws EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	public void ejbPassivate() throws EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	public void ejbRemove() throws RemoveException, EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	public void ejbStore() throws EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	public void unsetEntityContext() throws EJBException, RemoteException
  | 	{
  | 	}
  | 
  | 	/**
  | 	 * Getter for CMP Field lastName.
  | 	 * 
  | 	 * @return The person's lastname.
  | 	 * @ejb.persistent-field
  | 	 * @ejb.persistence column-name = "lastname" sql-type = "VARCHAR"
  | 	 * @ejb.interface-method view-type="local"
  | 	 */
  | 	public abstract String getLastName();
  | 
  | 	/**
  | 	 * Setter for CMP Field lastName.
  | 	 * 
  | 	 * @param pLastName The person's lastname
  | 	 * @ejb.interface-method view-type="local"
  | 	 */
  | 	public abstract void setLastName(String pLastName);
  | 
  | 	
  | 	/**
  | 	 * Create method.
  | 	 * 
  | 	 * @ejb.create-method view-type = "local"
  | 	 */
  | 	public Object ejbCreate(String pLastName) throws javax.ejb.CreateException
  | 	{
  | 		setLastName(pLastName);
  | 		return null;
  | 	}
  | 
  | 	public void ejbPostCreate(String pLastName, String pFirstName, Date pBirthday) throws javax.ejb.CreateException
  | 	{
  | 	}
  | 
  | 
  | 
  | }
  | 

as well as


  | package de.chitec.physio.server.ejb;
  | 
  | import java.rmi.RemoteException;
  | 
  | import javax.ejb.EJBException;
  | import javax.ejb.EntityBean;
  | import javax.ejb.EntityContext;
  | import javax.ejb.RemoveException;
  | 
  | import de.chitec.physio.server.interfaces.CMPPersonLocal;
  | 
  | /**
  |  * @ejb.bean 
  |  *  name="CMPPatient" 
  |  *  display-name="CMPPatient" 
  |  *  description="Description for CMPPatient"
  |  *  jndi-name="ejb/CMPPatient" 
  |  *  type="CMP" 
  |  *  cmp-version="2.x" 
  |  *  view-type="local" 
  |  *  reentrant = "false"
  |  *  local-jndi-name = "ejb/CMPPatient"
  |  *  
  |  * @ejb.persistence 
  |  *  table-name = "patient"
  |  * 
  |  * @ejb.pk
  |  *  class="java.lang.Object"
  |  *  
  |  * @jboss.entity-command 
  |  *  name = "${jboss.entity.command}" 
  |  *  class = "${jboss.entity.class}"
  |  *  
  |  * @jboss.unknown-pk 
  |  *  class="java.lang.Integer" 
  |  *  column-name="id" 
  |  *  jdbc-type="INTEGER" 
  |  *  sql-type="INTEGER"
  |  *  auto-increment="true"
  |  *  
  |  * @jboss.persistence 
  |  *  pk-constraint = "true" 
  |  *  table-name = "patient"
  |  */
  | public abstract class CMPPatientBean implements EntityBean {
  | 
  | 	public CMPPatientBean() {
  | 	}
  | 
  | 	public void ejbActivate() throws EJBException, RemoteException {
  | 	}
  | 
  | 	public void ejbLoad() throws EJBException, RemoteException {
  | 	}
  | 
  | 	public void ejbPassivate() throws EJBException, RemoteException {
  | 	}
  | 
  | 	public void ejbRemove() throws RemoveException, EJBException, RemoteException {
  | 	}
  | 
  | 	public void ejbStore() throws EJBException, RemoteException {
  | 	}
  | 
  | 	public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException {
  | 	}
  | 
  | 	public void unsetEntityContext() throws EJBException, RemoteException {
  | 	}
  | 
  | 	/**
  | 	 * Getter for CMR Relationship
  | 	 *
  | 	 * @ejb.interface-method   view-type="local"
  | 	 * @ejb.relation           name = "Patient-To-Person"
  | 	 *                         role-name = "Patient-To-Person-Role"
  | 	 *                         target-ejb = "CMPPerson"
  | 	 *                         target-role-name = "Patient-Is-Person"
  | 	 *                         target-multiple = "false"
  | 	 *                         
  | 	 * @jboss.relation  related-pk-field = "id"
  | 	 *                         fk-column = "person"
  | 	 * 						
  | 	 */
  | 	public abstract CMPPersonLocal getPerson();
  | 
  | 	/**
  | 	 * Setter for CMR Relationship
  | 	 *
  | 	 * @ejb.interface-method   view-type="local"
  | 	 */
  | 	public abstract void setPerson(CMPPersonLocal value);
  | 
  | }
  | 

As you can see both CMPs use automagically generated PKs. Now for the problem:

Both of the contained beans work well if not linked via a relation. As soon as the relation comes in we got a problem. I know how it is supposed to be done (using jbosscmp-jdbc.xml). The relation code should be:


  | <ejb-relation>
  |   <foreign-key-mapping/>
  |   <ejb-relation-name>Patient-To-Person</ejb-relation-name>
  |   <ejb-relationship-role>
  |     <ejb-relationship-role-name>
  |       Patient-To-Person-Role
  |     </ejb-relationship-role-name>
  |     <key-fields />
  |   </ejb-relationship-role>
  |   <ejb-relationship-role>
  |     <ejb-relationship-role-name>
  |       Patient-Is-Person
  |     </ejb-relationship-role-name>
  |   </ejb-relationship-role>
  | </ejb-relation>
  | 

The problem is: I simply don't know how to generate the <foreign-key-mapping/> tag via xdoclet.

Please, please, please - help.... :-)

Greetings

Sebastian

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995872#3995872

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995872



More information about the jboss-user mailing list