Re: Joins -- Details
[email protected] Wed, 25 Mar 2009 10:28:16 +1000
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
Hello Franck,
Looks a lot better. Thanks for adding the join code. It makes SimpleORM complete, even if it does add some complexity.
Details:-
+ SRelation is an odd name in English. "Relation" in relational algebra is just a fancy word for Table. It does not mean the relationship between tables. And there could be several SRelations for the same Table. I would suggest the SQL term SAlias, or maybe SQueryTable.
+ retrieveRecord: if ( fMeta.getRecordMeta() != inst.getMeta()) { cannot be right. What about joining Emp to Manager? Needs to know about Relations.
++ Due to the above I think that you need to push SRelation up through the code so that it is created by findInDatabase and not in SDriver.select.
I had tried not to create too many objects during query processing for performance reasons. But given where we are maybe we should just push the whole SQuery object up to findInDatabase. Would reduce the number of parameters to selectSQL, and the performance impact is probably negligible. Might clean up SQuery slightly eg. create the queryParameters List lazily. I'd like to profile this a bit, eg. measure your final version against the old version doing simple finds on HSQLDB (which is very fast and will highlight issues).
+ I'd personally prefer mainAlias to be mainRelation of type SRelation.
+ I am concerned about your use of SRelation.mustQuote. Generating queries like
FROM FOO "FOO", ...
is unusual at least, and so likely to cause compatibility problems with other databases.
Maybe if the alias is the same as the table name simply don't specify it at all?
Maybe generate default aliases being the first letter of the table followed by the number of tables in the query?
Eg. D2 if Department is the first joined table? (Just use relations.size()).
Would make the default generated queries neater.
(Then mustQuote can go completely.)
+ Renamings are incomplete, eg. appendTableName.
+ SException.Error("Duplicate alias in query. Table not added."); Should say which alias.
+ Maybe "SRelation" should go into its own file. SQuery is getting pretty big.
Regards,
Anthony
Dr Anthony Berglas, [email protected] Mobile: +61 4 4838 8874
Just because it is possible to push twigs along the ground with ones nose
does not necessarily mean that is the best way to collect firewood.
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/SimpleORM/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/SimpleORM/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/