Relation serialization

Forum for posting problems using QxOrm library

Relation serialization

Postby Guest » Fri Apr 29, 2011 10:20 am

Hi,
I would like to serialize an object which have a relation with another object.

1. Is it possible to serialize the foreign id only in place of the full associated object ?

2. The item is serialize to xml, then a remote process unserialize and insert it in a new database. The insert process return an error with foreign key is not valid. The associated object id is valid. Any idea about this problem?

Thanks,
Guest
 

Re: Relation serialization

Postby QxOrm admin » Mon May 02, 2011 8:43 am

Hi,

1. If your associated object is full fetched, so the serialization process will serialize the full associated object.
If you want to serializaze only the foreign id, you have to lazy fetch your relation.

2. What is your database : SQLite, MySql, PostgresSql, other ? boost version, Qt version ?
Can you send your error message and a code to reproduce your problem please ?
QxOrm admin
 

Re: Relation serialization

Postby Guest » Mon May 02, 2011 12:33 pm

1. lazy fecth means t.data() instead of t.relationOneToOne() ?

2. used components: postgresql 8.4, boot 1.45, xqorm 1.1.5
In fact the associated object does not exist in the target system. This is the problem.
Guest
 

Re: Relation serialization

Postby QxOrm admin » Mon May 02, 2011 3:26 pm

1- Lazy fetch means : use "qx::dao::fetch_by_id<T>" function instead of "qx::dao::fetch_by_id_with_relation<T>" function and "qx::dao::fetch_by_id_with_all_relation<T>" function.
In this case, your associated object will have only its id fetched (and not all properties).

2- In fact the associated object does not exist in the target system

So you have to insert your associated object first, no ?
Or set to NULL your associated object after your unserialization process.
I don't think that QxOrm library can resolve your problem automatically, you have to write some code to manage the associated object...
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 7 guests

cron