[odb-users] the id value from the qcreator is inconsistent with the visual studio

不明真相 icewill9999 at vip.qq.com
Thu Aug 15 03:37:18 EDT 2019


Hi all,


i started to learn and use odb 2.4.0 in my project, my team members like to use qt creator to develop our application. and i remove all the qt features of the project and use the MSVC as the building tools.


i defined a class with an id like this:
class BasinInfo{
#pragma db id auto
	unsigned long id_;

}


then i code like this:
shared_ptr<BasinInfo> binfo(new BasinInfo());
		cout << "id " << binfo->Id() << endl;



i get the result 3452816845, if i change the type of id to int, then i get -8421501541. all the results are not what i want, because if i run the code in visual studio i always get 0.
the value of  id is important to me is because i want to use the id value to decide the next operation.


if (binfo->Id() > 0) {
			//binfo was a persistent object, update it!
			db->update(binfo);
		}
		else {
			//this is a transient object, need to persist into the db
			db->persist(binfo);
		}



anyone knows how to fix it? thanks in advance!


Best Regards


More information about the odb-users mailing list