I am still having an issue here. I have now been working on this for about 3 solid days now. Please help!
I get the Allergies created as well as the MedicalHistory object in the DB, but the Allergies does not have a medical_history_id_fk so I have no way to find that Allergies from the Medical HistoryID.
Here is my methods in question: ====================
MedicalHistoryManagerBean: =================
public AllergiesDto allergiesCreate( AllergiesDto pAllergiesDto, Long pUserId )
throws EJBException
{
try
{
MedicalHistoryDto medicalHistoryDto = null;
try
{
medicalHistoryDto = this.findMedicalHistoryByUserId( pUserId );
}
catch( FinderException fe )
{
medicalHistoryDto = this.medicalHistoryCreate( pUserId );
}
log.info( "pAllergiesDto.setPrimaryKey( AllergiesUtil.generateGUID( pAllergiesDto ) );" );
String allergiesGUID = AllergiesUtil.generateGUID( pAllergiesDto );
pAllergiesDto.setPrimaryKey( allergiesGUID );
pAllergiesDto.setAllergiesId( allergiesGUID );
log.info( "pAllergiesDto.getPrimaryKey()" + pAllergiesDto.getPrimaryKey() );
log.info( "pAllergiesDto.getAllergiesId()" + pAllergiesDto.getAllergiesId() );
AllergiesUtil.getLocalHome().create( pAllergiesDto );
medicalHistoryDto.setAllergiesDto( pAllergiesDto );
log.info( "medicalHistoryDto = this.medicalHistoryUpdate( medicalHistoryDto, pUserId );" );
medicalHistoryDto = this.medicalHistoryUpdate( medicalHistoryDto, pUserId );
log.info( "return AllergiesUtil.getLocalHome().findByPrimaryKey( pAllergiesDto.getPrimaryKey() ).getAllergiesDto();" );
return AllergiesUtil.getLocalHome().findByPrimaryKey( pAllergiesDto.getPrimaryKey() ).getAllergiesDto();
}
catch( Throwable t )
{
// I think we need to distinguish between finder exceptions
// and other types of errors so we can correctly send the proper error back to the user.
throw new EJBException( t.getMessage() );
}
}
public MedicalHistoryDto medicalHistoryUpdate( MedicalHistoryDto pMedicalHistoryData, Long pUserId )
throws EJBException
{
try
{
MedicalHistoryLocalHome medicalHistoryLocalHome = MedicalHistoryUtil.getLocalHome();
MedicalHistoryLocal medicalHistoryLocal = null;
if( log.isInfoEnabled() )
{
log.info( "medicalHistoryUpdate()" );
log.info( "Update MedicalHistory Data with this: " + pMedicalHistoryData.toString() );
}
try
{
if( pMedicalHistoryData == null || pMedicalHistoryData.getMedicalHistoryId().equals( "" ) )
{
pMedicalHistoryData = new MedicalHistoryDto();
throw new EJBException( "MedicalHistoryData is null" );
}
medicalHistoryLocal = medicalHistoryLocalHome.findByPrimaryKey( pMedicalHistoryData.getMedicalHistoryId() );
}
catch( Throwable t )
{
String mhGUID = MedicalHistoryUtil.generateGUID( pMedicalHistoryData );
pMedicalHistoryData.setPrimaryKey( mhGUID );
pMedicalHistoryData.setMedicalHistoryId( mhGUID );
pMedicalHistoryData.setUserId( pUserId );
medicalHistoryLocal = medicalHistoryLocalHome.create( pMedicalHistoryData );
}
medicalHistoryLocal.setMedicalHistoryDto( pMedicalHistoryData );
return medicalHistoryLocal.getMedicalHistoryDto();
}
catch( Throwable t )
{
throw new EJBException( t.getMessage() );
}
}MedicalHistoryBean CMR:
================
/**
* Get Allergies for this medicalHistory.
*
* @ejb.interface-method
*
* @ejb.relation
* name="MedicalHistory-Allergies"
* role-name="medical_history-has-allergies"
* target-ejb="Allergies"
* --target-role-name="allergies-belongs_to-medical_history"
* --target-cascade-delete="yes"
*
* @ejb.value-object
* compose="com.baselogic.yoursos.user.AllergiesDto"
* compose-name="AllergiesDto"
* members="com.baselogic.yoursos.user.AllergiesLocal"
* members-name="AllergiesDto"
* relation="external"
*
* @ --jboss.relation
* --fk-column="allergies_id_fk"
* --related-pk-field="medicalHistoryId"
* --fk-contraint="true"
*/
public abstract AllergiesLocal getAllergies();
public abstract void setAllergies( AllergiesLocal pAllergiesLocal );AllergiesBean CMR:
============
/**
* Get the MedicalHistory for this Allergies
*
* @ejb.interface-method
*
* @ejb.relation
* name="MedicalHistory-Allergies"
* role-name="allergies-belongs_to-medical_history"
* target-ejb="Allergies"
*
* @jboss.relation
* fk-column="medical_history_id_fk"
* related-pk-field="medicalHistoryId"
**/
public abstract MedicalHistoryLocal getMedicalHistory();
public abstract void setMedicalHistory( MedicalHistoryLocal pMedicalHistory );
I have set up a 1-1 unidirectional relationship just like the xPetstore, but it does not seem to work at all. I don't get errors, but the relationship does not update. I have a MedicalHistoryDto that has an AllergiesDto. I can populate the Allergies by itself like a standalone bean, but not like medicalHistoryDto.setAllergiesDto( allergiesDto );
My Code: ========================= /** * Get Allergies for this medicalHistory. * * @ejb.interface-method * * @ejb.relation * name="MedicalHistory-Allergies" * role-name="medical_history-has-allergies" * target-ejb="Allergies" * target-role-name="allergies-belongs_to-medical_history" * target-cascade-delete="yes" * * @ejb.value-object * compose="com.baselogic.yoursos.user.AllergiesDto" * compose-name="AllergiesDto" * members="com.baselogic.yoursos.user.AllergiesLocal" * members-name="AllergiesDto" * relation="external" * * @jboss.relation * fk-column="allergies_id_fk" * related-pk-field="medicalHistoryId" * fk-contraint="true" */ public abstract AllergiesLocal getAllergies(); public abstract void setAllergies( AllergiesLocal pAllergiesLocal );
/** * Retrieve the MedicalHistory's ID. * * @ejb.pk-field * @ejb.persistent-field * @ejb.interface-method * @ejb.transaction * type="NotSupported" * @jboss.column-name name="medical_history_id" **/ public abstract java.lang.String getMedicalHistoryId();
/**
* No interface method for setMedicalHistoryId(..). See page 130 of the EJB 2.0 specification:
* "Once the primary key for an entity bean has been set, the Bean Provider must
* not attempt to change it by use of set accessor methods on the primary key
* cmp-fields. The Bean provider should therefore not expose the set accessor
* methods for the primary key cmp-fields in the component interface of the
* entity bean.". A work around would be to remove and then an re-create the bean.
*/
public abstract void setMedicalHistoryId( java.lang.String pMedicalHistoryId );
---
Thanks...
Mick Knutson
---
I have set up a 1-1 unidirectional relationship just like the xPetstore, but it does not seem to work at all. I don't get errors, but the relationship does not update. I have a MedicalHistoryDto that has an AllergiesDto. I can populate the Allergies by itself like a standalone bean, but not like medicalHistoryDto.setAllergiesDto( allergiesDto );
My Code: ========================= /** * Get Allergies for this medicalHistory. * * @ejb.interface-method * * @ejb.relation * name="MedicalHistory-Allergies" * role-name="medical_history-has-allergies" * target-ejb="Allergies" * target-role-name="allergies-belongs_to-medical_history" * target-cascade-delete="yes" * * @ejb.value-object * compose="com.baselogic.yoursos.user.AllergiesDto" * compose-name="AllergiesDto" * members="com.baselogic.yoursos.user.AllergiesLocal" * members-name="AllergiesDto" * relation="external" * * @jboss.relation * fk-column="allergies_id_fk" * related-pk-field="medicalHistoryId" * fk-contraint="true" */ public abstract AllergiesLocal getAllergies(); public abstract void setAllergies( AllergiesLocal pAllergiesLocal );
/** * Retrieve the MedicalHistory's ID. * * @ejb.pk-field * @ejb.persistent-field * @ejb.interface-method * @ejb.transaction * type="NotSupported" * @jboss.column-name name="medical_history_id" **/ public abstract java.lang.String getMedicalHistoryId();
/**
* No interface method for setMedicalHistoryId(..). See page 130 of the EJB 2.0 specification:
* "Once the primary key for an entity bean has been set, the Bean Provider must
* not attempt to change it by use of set accessor methods on the primary key
* cmp-fields. The Bean provider should therefore not expose the set accessor
* methods for the primary key cmp-fields in the component interface of the
* entity bean.". A work around would be to remove and then an re-create the bean.
*/
public abstract void setMedicalHistoryId( java.lang.String pMedicalHistoryId );
--- Thanks... Mick Knutson ---
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
