Create a relationship for Many-to-Many table

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

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

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

[quote=Jick]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[/quote]

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