What's the depth of relation?

Forum for posting problems using QxOrm library

What's the depth of relation?

Postby magicu » Sat Jan 21, 2012 8:06 am

Take qxBlog for example:

When I get a blog from fetch_by_id_with_all_relation(blog), then I get the blog's author which stores in blog->m_author.

Now, If I can get all blog records which have relation to m_author? The length of blog->m_author->m_blogX is zero in my test. I think the Linq & Nibernate can implement this. Do I have to query for a second time?


In something alike scene:

I have 3 tables, which have relation like A->B->C. C is the grandfather of A.

When I get a C, How to travel B and A?
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: What's the depth of relation?

Postby QxOrm admin » Sat Jan 21, 2012 9:01 am

Hi,

The depth for relationships is 2 tables : this is a limitation today of QxOrm library.
It's planned to improve this behaviour for QxOrm 1.2.3 (so not the next version, but version after).

So in your case, your have to call a second query to fetch all datas.
Or, another solution would be to create a view into your database, and create a C++ class to map to this view...
QxOrm admin
 

Re: What's the depth of relation?

Postby magicu » Thu Feb 09, 2012 1:58 pm

QxOrm admin wrote:Hi,

The depth for relationships is 2 tables : this is a limitation today of QxOrm library.
It's planned to improve this behaviour for QxOrm 1.2.3 (so not the next version, but version after).

So in your case, your have to call a second query to fetch all datas.
Or, another solution would be to create a view into your database, and create a C++ class to map to this view...




Is there a QxOrm 1.2.3 or a beta version released to solve the depth limit?
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: What's the depth of relation?

Postby QxOrm admin » Thu Feb 09, 2012 7:40 pm

Is there a QxOrm 1.2.3 or a beta version released to solve the depth limit?

No, not yet :!:
It will be the main improvement of the next version (1.2.3), but you have to wait...
QxOrm admin
 

Re: What's the depth of relation?

Postby magicu » Thu Apr 12, 2012 1:58 pm

QxOrm admin wrote:
Is there a QxOrm 1.2.3 or a beta version released to solve the depth limit?

No, not yet :!:
It will be the main improvement of the next version (1.2.3), but you have to wait...


I notice that 1.2.3 has been released, Have you improved this function?
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: What's the depth of relation?

Postby QxOrm admin » Thu Apr 12, 2012 2:13 pm

QxOrm 1.2.3 has been released because there was enough news and interesting features (especially the new interface qx::IxPersistable : http://www.qxorm.com/qxorm_en/faq.html#faq_260).
Sorry, but you have to wait the next version for the depth relation limit improvement.
However, with QxOrm 1.2.3, there is new triggers that you can use to fetch 2, 3, 4 or more levels of relationships with only 1 call : you can use the new onAfterFetch() trigger to implement this feature (more detail into the FAQ here : http://www.qxorm.com/qxorm_en/faq.html#faq_130).

This is really complicated to implement a good engine to remove the depth limit and I don't want to break the actual engine because it works fine (and with very good performance).
But don't worry, I think about it and I will notice you as soon as this new feature will be available...
QxOrm admin
 

Re: What's the depth of relation?

Postby magicu » Thu Apr 12, 2012 3:06 pm

QxOrm admin wrote:QxOrm 1.2.3 has been released because there was enough news and interesting features (especially the new interface qx::IxPersistable : http://www.qxorm.com/qxorm_en/faq.html#faq_260).
Sorry, but you have to wait the next version for the depth relation limit improvement.
However, with QxOrm 1.2.3, there is new triggers that you can use to fetch 2, 3, 4 or more levels of relationships with only 1 call : you can use the new onAfterFetch() trigger to implement this feature (more detail into the FAQ here : http://www.qxorm.com/qxorm_en/faq.html#faq_130).

This is really complicated to implement a good engine to remove the depth limit and I don't want to break the actual engine because it works fine (and with very good performance).
But don't worry, I think about it and I will notice you as soon as this new feature will be available...


Thank you, I'll come here sometime later:)
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: What's the depth of relation?

Postby QxOrm admin » Fri Apr 27, 2012 2:45 pm

Hi,

Here is a BETA version of QxOrm 1.2.4 including the new feature you are waiting for (QxOrm 1.2.4 BETA 14) :
http://www.qxorm.com/version/QxOrm_1.2.4_BETA_14.zip

With this version, you can fetch many levels of relationships.
For example, using qxBlog tutorial, you can now write something like this if you want to fetch :
1- a blog with its author ;
2- for the author fetched, I want all blogs he has written ;
3- and for all blogs fetched, I want all comments associated.
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("author_id->list_blog->list_comment", blog_tmp);


You can also create a list of relationships to fetch, like this :
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QStringList relation;
relation << "author_id->list_blog->list_comment";
relation << "author_id->list_blog->list_category";
relation << "list_comment";
relation << "list_category";
QSqlError daoError = qx::dao::fetch_by_id_with_relation(relation, blog_tmp);


To fetch all relationships per level, you can use the "*" keyword.
For examples, if you want to fetch all relationships with a depth of 3, you can write :
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("*->*->*", blog_tmp);


Note : operator "->" between 2 relations means "LEFT OUTER JOIN".
If you want to join 2 relations using "INNER JOIN", you have to use the ">>" operator, for example :
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("author_id>>list_blog>>list_comment", blog_tmp);


Now I need your help to test this BETA version, this new feature, and to be sure that there is no regression !
Thanx in advance for all your future tests...

Note : I will write a documentation about this new feature...
QxOrm admin
 

Re: What's the depth of relation?

Postby magicu » Sat Jun 02, 2012 5:49 am

QxOrm admin wrote:Hi,

Here is a BETA version of QxOrm 1.2.4 including the new feature you are waiting for (QxOrm 1.2.4 BETA 14) :
http://www.qxorm.com/version/QxOrm_1.2.4_BETA_14.zip

With this version, you can fetch many levels of relationships.
For example, using qxBlog tutorial, you can now write something like this if you want to fetch :
1- a blog with its author ;
2- for the author fetched, I want all blogs he has written ;
3- and for all blogs fetched, I want all comments associated.
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("author_id->list_blog->list_comment", blog_tmp);


You can also create a list of relationships to fetch, like this :
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QStringList relation;
relation << "author_id->list_blog->list_comment";
relation << "author_id->list_blog->list_category";
relation << "list_comment";
relation << "list_category";
QSqlError daoError = qx::dao::fetch_by_id_with_relation(relation, blog_tmp);


To fetch all relationships per level, you can use the "*" keyword.
For examples, if you want to fetch all relationships with a depth of 3, you can write :
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("*->*->*", blog_tmp);


Note : operator "->" between 2 relations means "LEFT OUTER JOIN".
If you want to join 2 relations using "INNER JOIN", you have to use the ">>" operator, for example :
Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("author_id>>list_blog>>list_comment", blog_tmp);


Now I need your help to test this BETA version, this new feature, and to be sure that there is no regression !
Thanx in advance for all your future tests...

Note : I will write a documentation about this new feature...




I just receive your message and sorry for late, I notice you had released the 1.2.4, what can I do for you now :)

Fetch multiple levels of relationships is great function that I expected for a long time. Thank you very much!


Does the QxOrm multiple levels fetch is eager or lazy one?
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: What's the depth of relation?

Postby QxOrm admin » Sat Jun 02, 2012 3:06 pm

Does the QxOrm multiple levels fetch is eager or lazy one ?

Here is a new Q&R in the FAQ to explain how to fetch datas :
http://www.qxorm.com/qxorm_en/faq.html#faq_270
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 7 guests

cron