[odb-users] Assign raw foreign key id without using a loaded
	object
    Boris Kolpackov 
    boris at codesynthesis.com
       
    Tue Sep 25 04:51:34 EDT 2012
    
    
  
Hi Rene,
Rene Jensen <rene at catatonic.dk> writes:
> Say I have an object with a QLazyWeakPointer to some other class.
> Can I assign a reference to a different id without having to load the
> referred object into memory first, by simply using e.g. an integer key (if
> my foreign key database type was INTEGER, of course):
> 
> QSharedPointer<Format> F = ... load_format(10) ... bla bla
> 
> P->format = 10;
> P->format = F;
Yes, you can initialize an unloaded lazy pointer with just an ID (and
a reference to the database):
P->format = QLazyWeakPointer<Format> (db, 10);
This is discussed at the end of Section 6.4, "Lazy Pointers" in the
ODB manual.
Boris
    
    
More information about the odb-users
mailing list