qx::dao::update_optimized ??
Posted: Thu Aug 28, 2014 3:24 pm
Hello,
I am trying to implement persistent classes that will perform a database update inside each property setter. Ideally, I would like to see only the columns affected by the setter being updated, which is why I chose the qx::dao::update_optimized() function. Heres the issues that I have:
1. the qx::dao::update_optimized function takes a qx::dao::ptr argument, which dont seem to be able to obtain other than by creating it locally. This seems quite strange, as I have to also prevent the ptr to delete my object when it goes out of scope (see code below). Is there a better way?
2. the SQL update statement generated references all columns, which is what I wanted to avoid.
I am trying to implement persistent classes that will perform a database update inside each property setter. Ideally, I would like to see only the columns affected by the setter being updated, which is why I chose the qx::dao::update_optimized() function. Heres the issues that I have:
1. the qx::dao::update_optimized function takes a qx::dao::ptr argument, which dont seem to be able to obtain other than by creating it locally. This seems quite strange, as I have to also prevent the ptr to delete my object when it goes out of scope (see code below). Is there a better way?
2. the SQL update statement generated references all columns, which is what I wanted to avoid.
- Code: Select all
static void dontdelete(ProjectDefaults *obj)
{
}
void ProjectDefaults::setHoursLaborPerCowYearP(const int & val)
{
setHoursLaborPerCowYear(val);
qx::dao::ptr<ProjectDefaults> ptr(this, dontdelete);
qx::dao::update_optimized(ptr);
}