Visual Paradigm Logo
     Build Quality Applications Faster, Better and Cheaper
 
Home | Products | Download | Documentation | Support | Resources | Partners | Quick Tour | Shop | Company |  
 
   Visual Paradigm Discussion Forum
  Login   [ Register ] Email: Password: Log me on automatically I lost my password  
Recent Topics
Advanced Search
Create a relationship for Many-to-Many table.  
Forum Index -> DB Visual ARCHITECT (DB-VA)
Author Message
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
 
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
 
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

Jick wrote:
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 
 
Jick


Joined: 2005/04/29
Messages: 2880

Offline

Dear jvence,

Please check if the following code sample could help:
Code:
 
 //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
 
 
   Forum Index -> DB Visual ARCHITECT (DB-VA)
Go to:   
Powered by JForum 2.1.4 © 2005 - Rafael Steil