| Author |
Message |
|
2006/11/16 07:58
|
|
|
jvence
Joined: 2005/09/15
Messages: 17
Offline
|
|
|
|
Basically, I have two entities that have a many-to-many relationship so 3 tables are created in the DB. I can insert a record for my 2 entities using the generated POJOs but how do I create a relationship (a record in the many to many table)? The Pojo doesn't seem to provide anyway to create this relationship.
Thanks
|
|
|
|
 |
| |
|
2006/11/16 18:07
|
|
|
Jick
Joined: 2005/04/29
Messages: 2880
Offline
|
|
|
|
Hi jvence,
I guess that you want to add records to the Link table (the extra table created by the many-to-many relationship). Actually, there should not be a class for the Link table. You just need to use the POJO as usual, and the underlying persistence tier will do the mapping for you - create the records to the appropriate table in the database.
Hope this helps. Please feel free to let me know if there are any questions.
Best regards,
Jick
|
Visual Paradigm International Ltd.
http://www.visual-paradigm.com
Build Quality Applications Faster, Better and Cheaper |
|
|
|
 |
| |
|
2006/11/16 22:23
|
|
|
jvence
Joined: 2005/09/15
Messages: 17
Offline
|
|
|
|
Yes, I'm trying to add a record to the Link table. There's nothing in the individual POJOs that would let me create an association in the Link table (except perhaps the getORMxxx (which returns a set of the association), then adding to this set and using setORMxxx to save it back. BTW the functions that deals with retrieving/setting the set of association are private.
Do you have any example on how to do this?
Jean
Hi jvence,
I guess that you want to add records to the Link table (the extra table created by the many-to-many relationship). Actually, there should not be a class for the Link table. You just need to use the POJO as usual, and the underlying persistence tier will do the mapping for you - create the records to the appropriate table in the database.
Hope this helps. Please feel free to let me know if there are any questions.
Best regards,
Jick
|
|
|
|
|
 |
| |
|
2006/11/17 11:20
|
|
|
Jick
Joined: 2005/04/29
Messages: 2880
Offline
|
|
|
|
Dear jvence,
Please check if the following code sample could help:
//entity EA
demo.EA ldemoEA = new demo.EA();
//...
//entity EB
demo.EB ldemoEB = new demo.EB();
//...
//link entity
demo.EA_Entity ldemoEA_Entity = new demo.EA_Entity();
//...
ldemoEA_Entity.setEAidA(ldemoEA);
ldemoEA_Entity.setEBidB(ldemoEB);
//save objects
orm.P25PersistentManager.instance().getSession().save(ldemoEA);
orm.P25PersistentManager.instance().getSession().save(ldemoEB);
orm.P25PersistentManager.instance().getSession().save(ldemoEA_Entity);
|
Best regards,
Jick
|
Visual Paradigm International Ltd.
http://www.visual-paradigm.com
Build Quality Applications Faster, Better and Cheaper |
|
|
|
 |
| |