Re: [JBoss-user] relate 2 entities without a common key (WAS Re: [JBoss-user] relationship 1-* with foreign key)
Unless it is many-to-many relationship you should use either @jboss.relation or @jboss.target-relation tags. Pedro Salazar wrote: Greetings, -I have 2 entities mapped from 2 database tables, ACCESS_PERMISSION and ACCESS_SCHEDULE. -the relation between them is, ACCESS_PERMISSION *has* several ACCESS_SCHEDULE, and a 1-N -*they don't share a common key* ACCESS_PERMISSION - SID_ID SERVICE_ID A1 A2 ... CONSTRAINS: UNIQUE (SID_ID,SERVICE_ID) ACCESS_SCHEDULE --- SID_ID SERVICE_ID TIME_ACCESS_START B1 B2 CONSTRAINTS: UNIQUE(SID_ID,SERVICE_ID,TIME_ACCESS_START) Can I define a relationship between them? I tried to use a relation just with 2 attributes of table ACCESS_SCHEDULE and not using the 3rd one (TIME_ACCESS_START) but JBOSS shows me that error: [ObjectName: jboss.j2ee:jndiName=ejb/AccessScheduleLocal,service=EJB state: FAILED I Depend On: Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[timeAccessStart] in role=schedules_BELONG_TO_access_permission, ObjectName: jboss.j2ee:jndiName=ejb/AccessPermissionLocal,service=EJB state: FAILED I Depend On: Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[timeAccessStart] in role=schedules_BELONG_TO_access_permission] Can I do this in another way? What is normal to do, a findByXX() method in ACCESS_SCHEDULE and a interface method on ACCESS_PERMISSION? But in that case, there must exist some programatic code and I don't know how can I synchronize access to that methods? To complete, I put in below also the xdoclet code of my relationship: /** * @ejb.relation * name=access_permission_TO__access_schedule * role-name=access_permission_HAS_schedules * cascade-delete=no * target-ejb=AccessSchedule * target-role-name=schedules_BELONG_TO_access_permission * target-cascade-delete=yes * @ejb.interface-method * view-type=local * @ejb.transaction * type=Supports * @jboss.relation * related-pk-field=sidId * fk-column=sidId * @jboss.relation * related-pk-field=primitiveId * fk-column=primitiveId * @jboss.target-relation * related-pk-field=sidId * fk-column=sidId * @jboss.target-relation * related-pk-field=primitiveId * fk-column=primitiveId * @jboss.relation-mapping * style=relation-table * @jboss.relation-table * table-name=uif_access_permission */ public abstract java.util.Collection getSchedules(); regards, Pedro Salazar --- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] relate 2 entities without a common key (WAS Re: [JBoss-user] relationship 1-* with foreign key)
Greetings, -I have 2 entities mapped from 2 database tables, ACCESS_PERMISSION and ACCESS_SCHEDULE. -the relation between them is, ACCESS_PERMISSION *has* several ACCESS_SCHEDULE, and a 1-N -*they don't share a common key* ACCESS_PERMISSION - SID_ID SERVICE_ID A1 A2 ... CONSTRAINS: UNIQUE (SID_ID,SERVICE_ID) ACCESS_SCHEDULE --- SID_ID SERVICE_ID TIME_ACCESS_START B1 B2 CONSTRAINTS: UNIQUE(SID_ID,SERVICE_ID,TIME_ACCESS_START) Can I define a relationship between them? I tried to use a relation just with 2 attributes of table ACCESS_SCHEDULE and not using the 3rd one (TIME_ACCESS_START) but JBOSS shows me that error: [ObjectName: jboss.j2ee:jndiName=ejb/AccessScheduleLocal,service=EJB state: FAILED I Depend On: Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[timeAccessStart] in role=schedules_BELONG_TO_access_permission, ObjectName: jboss.j2ee:jndiName=ejb/AccessPermissionLocal,service=EJB state: FAILED I Depend On: Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[timeAccessStart] in role=schedules_BELONG_TO_access_permission] Can I do this in another way? What is normal to do, a findByXX() method in ACCESS_SCHEDULE and a interface method on ACCESS_PERMISSION? But in that case, there must exist some programatic code and I don't know how can I synchronize access to that methods? To complete, I put in below also the xdoclet code of my relationship: /** * @ejb.relation * name=access_permission_TO__access_schedule * role-name=access_permission_HAS_schedules * cascade-delete=no * target-ejb=AccessSchedule * target-role-name=schedules_BELONG_TO_access_permission * target-cascade-delete=yes * @ejb.interface-method * view-type=local * @ejb.transaction * type=Supports * @jboss.relation * related-pk-field=sidId * fk-column=sidId * @jboss.relation * related-pk-field=primitiveId * fk-column=primitiveId * @jboss.target-relation * related-pk-field=sidId * fk-column=sidId * @jboss.target-relation * related-pk-field=primitiveId * fk-column=primitiveId * @jboss.relation-mapping * style=relation-table * @jboss.relation-table * table-name=uif_access_permission */ public abstract java.util.Collection getSchedules(); regards, Pedro Salazar -- -PS --- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] relate 2 entities without a common key (WAS Re: [JBoss-user] relationship 1-* with foreign key)
I will give you an example of an 1 - N relation using XDoclet tags. Using this code you can easisly figure out what to put in your code: Advertisement --1N-- Correction AdvertisementBean.java: /** * @ejb.interface-method * @ejb.relation * name = Advertisement-Correction * role-name = AdvertisementHasCorrections * cascade-delete = no * @ejb.value-object * aggregate = nl.informatiefabriek.om.correction.value.CorrectionValue * aggregate-name = AllCorrection * members = nl.informatiefabriek.om.correction.interfaces.CorrectionLocal * members-name = Corrections * relation = external * type = Collection * @jboss.relation-mapping style=foreign-key */ public abstract Collection getCorrections(); CorrectionBean.java: /** * @ejb.interface-method * @ejb.relation * name = Advertisement-Correction * role-name = CorrectionBelongsToAdvertisement * cascade-delete = yes * @jboss.relation-mapping style = foreign-key * @jboss.relation * fk-column=advertisement_fk * related-pk-field=advertisementId */ public abstract AdvertisementLocal getAdvertisement(); If you don't need relationships between value objects you can just leave out he @ejb.value-object tags. Regards, Harm de Laat Informatiefabriek The Netherlands Pedro Salazar [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 11/06/2003 11:08 AM Please respond to [EMAIL PROTECTED] To [EMAIL PROTECTED] cc Subject [JBoss-user] relate 2 entities without a common key (WAS Re: [JBoss-user] relationship 1-* with foreign key) Greetings, -I have 2 entities mapped from 2 database tables, ACCESS_PERMISSION and ACCESS_SCHEDULE. -the relation between them is, ACCESS_PERMISSION *has* several ACCESS_SCHEDULE, and a 1-N -*they don't share a common key* ACCESS_PERMISSION - SID_ID SERVICE_ID A1 A2 ... CONSTRAINS: UNIQUE (SID_ID,SERVICE_ID) ACCESS_SCHEDULE --- SID_ID SERVICE_ID TIME_ACCESS_START B1 B2 CONSTRAINTS: UNIQUE(SID_ID,SERVICE_ID,TIME_ACCESS_START) Can I define a relationship between them? I tried to use a relation just with 2 attributes of table ACCESS_SCHEDULE and not using the 3rd one (TIME_ACCESS_START) but JBOSS shows me that error: [ObjectName: jboss.j2ee:jndiName=ejb/AccessScheduleLocal,service=EJB state: FAILED I Depend On: Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[timeAccessStart] in role=schedules_BELONG_TO_access_permission, ObjectName: jboss.j2ee:jndiName=ejb/AccessPermissionLocal,service=EJB state: FAILED I Depend On: Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[timeAccessStart] in role=schedules_BELONG_TO_access_permission] Can I do this in another way? What is normal to do, a findByXX() method in ACCESS_SCHEDULE and a interface method on ACCESS_PERMISSION? But in that case, there must exist some programatic code and I don't know how can I synchronize access to that methods? To complete, I put in below also the xdoclet code of my relationship: /** * @ejb.relation * name=access_permission_TO__access_schedule * role-name=access_permission_HAS_schedules * cascade-delete=no * target-ejb=AccessSchedule * target-role-name=schedules_BELONG_TO_access_permission * target-cascade-delete=yes * @ejb.interface-method * view-type=local * @ejb.transaction * type=Supports * @jboss.relation * related-pk-field=sidId * fk-column=sidId * @jboss.relation * related-pk-field=primitiveId * fk-column=primitiveId * @jboss.target-relation * related-pk-field=sidId * fk-column=sidId * @jboss.target-relation * related-pk-field=primitiveId * fk-column=primitiveId * @jboss.relation-mapping * style=relation-table * @jboss.relation-table * table-name=uif_access_permission */ public abstract java.util.Collection getSchedules(); regards, Pedro Salazar -- -PS --- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored
Re: [JBoss-user] relate 2 entities without a common key (WAS Re: [JBoss-user] relationship 1-* with foreign key)
On Thu, 2003-11-06 at 10:57, [EMAIL PROTECTED] wrote: I will give you an example of an 1 - N relation using XDoclet tags. Using this code you can easisly figure out what to put in your code: Advertisement --1N-- Correction AdvertisementBean.java: /** * @ejb.interface-method * @ejb.relation * name = Advertisement-Correction * role-name = AdvertisementHasCorrections * cascade-delete = no * @ejb.value-object * aggregate = nl.informatiefabriek.om.correction.value.CorrectionValue * aggregate-name = AllCorrection * members = nl.informatiefabriek.om.correction.interfaces.CorrectionLocal * members-name = Corrections * relation = external * type = Collection * @jboss.relation-mapping style=foreign-key */ public abstract Collection getCorrections(); CorrectionBean.java: /** * @ejb.interface-method * @ejb.relation * name = Advertisement-Correction * role-name = CorrectionBelongsToAdvertisement * cascade-delete = yes * @jboss.relation-mapping style = foreign-key * @jboss.relation * fk-column=advertisement_fk * related-pk-field=advertisementId */ public abstract AdvertisementLocal getAdvertisement(); If you don't need relationships between value objects you can just leave out he @ejb.value-object tags. Hi, Could you please show me what keys are you using on your relation? To build a relationship you must have the same key on both sides of the relation, right? If not, JBOSS throws an error. Since I don't have it, I only could made a ejbSelect, but I don't know what I'm losing on a select besides the CASCADE_DELETE. What is the performance gain/loose of using relationship, select or a value-object? What is value-object aggregation ? thanks, Pedro Salazar. -- -PS --- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user