Many2Many Relationship Lifecycle Management

Open discussion on QxOrm library

Many2Many Relationship Lifecycle Management

Postby Kasuax » Mon Nov 14, 2016 11:00 pm

How do you typically manage Many2Many relationships?

Without a lot of build up I'm realizing that I'm going to have to do a lot of manual prep work to make these guys work. Particularly with delete it would appear. Will I have to implement custom onBeforeDelete operations for these objects? What would those functions look like? Below is where I'm currently at and admittedly struggling through this concept.

Code: Select all
void Project::onBeforeDelete(qx::dao::detail::IxDao_Helper * dao)
{   
    qx::QxSqlQuery query("WHERE t_qxee_User_Project.project_id = :key");
    query.bind(":key", m_Project_ID.toString());
   
    if (!qxTryCatch(qx::dao::execute_query(query, dao->database())))
    {
        qx::QxInvalidValueX msg;
        msg.insert("Unable to detach project from user accounts!");

        dao->addInvalidValues(msg);
    }
}
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: Many2Many Relationship Lifecycle Management

Postby qxorm » Tue Nov 15, 2016 7:57 am

Will I have to implement custom onBeforeDelete operations for these objects?

No.

What is your problem exactly ? I don't understand.

What you could do if you prefer is to split your n-n relationship to two n-1 and 1-n relationships.
This is what QxEntityEditor do for example during an import process : QxEntityEditor never creates automatically a n-n relationship.
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Open discussion

Who is online

Users browsing this forum: No registered users and 2 guests