I have the following relation structure in my DB:
Process could have many Objects, and every Object could participate in many Processes (many-to-many)
Object could have many Documents attached (one-to-many)
Document could consist of many Files (one-to-many)
each of Process, Object, Document have certain Type (many-to-one, types for each entity are stored in separate tables)
related .hpp and .cc files are attached (simplified for this post, so they could or could not be compiled; also they are relevant to my post in viewtopic.php?f=2&t=86#p1053)
I try to fetch multiple levels of relation hierarchy in one query.
When I define relations like this:
- Code: Select all
const QStringList ProcessDAO::relations__(
QStringList()
<< "process_type_id"
<< "Object_list->Document_list->document_type_id"
<< "Object_list->object_type_id"
<< "Object_list->Document_list->File_list"
);
I get the following SQL (field defs part omitted, relations only):
- Code: Select all
FROM "Process"
LEFT OUTER JOIN "ProcessType" "ProcessType_1"
ON "ProcessType_1"."id" = "Process"."process_type_id"
LEFT OUTER JOIN "ProcessObject" "ProcessObject_8"
ON "Process"."id" = "ProcessObject_8"."process_id"
LEFT OUTER JOIN "Object" "Object_8"
ON "ProcessObject_8"."object_id" = "Object_8"."id"
LEFT OUTER JOIN "Document" "Document_12"
ON "Document_12"."object_id" = "Object_8"."id"
LEFT OUTER JOIN "File" "File_16"
ON "File_16"."document_id" = "Document_12"."id"
no object type, nor document type
When I shuffle relations like this:
- Code: Select all
const QStringList ProcessDAO::relations__(
QStringList()
<< "process_type_id"
<< "Object_list->Document_list->document_type_id"
<< "Object_list->Document_list->File_list"
<< "Object_list->object_type_id"
I get object type, but no documents:
- Code: Select all
FROM "Process"
LEFT OUTER JOIN "ProcessType" "ProcessType_1"
ON "ProcessType_1"."id" = "Process"."process_type_id"
LEFT OUTER JOIN "ProcessObject" "ProcessObject_8"
ON "Process"."id" = "ProcessObject_8"."process_id"
LEFT OUTER JOIN "Object" "Object_8"
ON "ProcessObject_8"."object_id" = "Object_8"."id"
LEFT OUTER JOIN "ObjectType" "ObjectType_9"
ON "ObjectType_9"."id" = "Object_8"."object_type_id"
So, looks like QxOrm takes the last complicated relation from the list with the same head part. Though, documentation states that this kind of complicated relations could be used.
Please advice the solution for this problem.
I use Linter 6.1 (http://www.linter.ru/en/main/) DB engine, it has QT connector and works OK with pure QT.
PS:
QxOrm 1.2.5
QT 5.0.1
boost 1.53.0