Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Mick Knutson <mickknutson@ho...> - 2003-06-25 21:49:55
|
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 --- _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus |
From: Mick Knutson <mickknutson@ho...> - 2003-06-26 21:05:51
|
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 |
From: Ingo Bruell <ibruell@gm...> - 2003-06-27 12:01:38
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Mick, > 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. You need a finder to get it, something like: @ejb.finder signature="..." query="SELECT OBJECT(o) FROM Allergies as o WHERE o.medicalHistory.id = ?1" best regards Ingo Bruell - - --- <ibruell@...> <ICQ# 40377720> Oldenburg PGP-Fingerprint: CB01 AE12 B359 87C4 BF1C 953C 8FE7 C648 169E E5FC Germany PGP-Public-Key available at pgpkeys.mit.edu -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com> iQA/AwUBPvwj/4/nxkgWnuX8EQJYlwCgkeSuc/FprhKdGRAij9N5BQ9BwekAn1/V ylVTbXZab7UQNq0MP9YLFnWp =tijH -----END PGP SIGNATURE----- |