[odb-users] ODB Help.
Boris Kolpackov
boris at codesynthesis.com
Mon May 16 10:22:00 EDT 2011
Hi,
In the future please keep your replies CC'ed to the odb-users mailing
list as discussed in the posting guidelines:
http://www.codesynthesis.com/support/posting-guidelines.xhtml
art at it-gen.net writes:
> So we have an external rating system that counts every day rating, and
> it does not matter to us as operations rating renewed in ODB, but
> important to the previous value rating which now sits in a cache
> program, not erased numbered rating that sits in the database.
>
> Thats why we shared an one ODB object in two objects, and imitate
> readonly follows - 2nd object only read from the database and do not
> write in database.
Ok, if I understand you correctly, you can emulate this behavior by
adding a transient "cache" member (which is not stored in the databse)
to your persistent class. For example:
#pragma db object
class post
{
public:
post (unsigned int initial_rating)
: rating_ (initial_rating),
initial_rating_ (initial_rating)
{
}
unsigned int
initial_rating () const
{
return initial_rating_;
}
private:
unsigned int rating_;
#pragma db transient
unsigned int initial_rating_;
};
Would this work for you?
Boris
More information about the odb-users
mailing list