Re: Alias syntax
Franck Routier <[email protected]> Fri, 27 Mar 2009 10:22:30 +0100
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <1238145750.19053.16.camel@franck-laptop> |
Hello Anthony,
>
> I don't understand SQuery.alias. Seems redundant (and thus a little
> dangerous). Why not just search through tables.tableAlias directly?
Done. Removed aliases list.
>
> I like not having redundant aliases in FROM clauses. My only current
> concern is the readability of SELECT XX_DEPARTMENT.DEPT_ID,
> XX_DEPARTMENT.DNAME... Not important, but one little trick might be
> that if there is only one query table then suppress the XX_DEPARTMENT.
> prefix. Remember that that is the common case. Why does the first
> selectSQL method prepend table names given that it can only provide
> one table?
Done. We only prefix column names if there is more than one table (or a
rawJoin).
>
> The relationship between the selectSQL methods and SQueryExecute is
> not as clean as it could be. Why are WHERE clauses created one way,
> but JOIN clauses a different way? But let's leave that alone for now.
>
Yes...
> Bumping up the version number sounds good. Delete the commented out
> deprecated methods. There is a big comment block on top of the first
> innerJoin() that should be dealt with. Maybe reorder the methods in
> SQuery a bit, eg. group Join related ones? Also need to update the
> README.html in the website area to note that you have made these
> changes. Plus the white paper.
Done, except for the white paper...
>
> Once you have finished I was thinking of making SRecordInstance
> implement Map of field names (as strings) to field values. This means
> that results of queries are Lists of Maps, very standard Java. Means
> it can be reflected upon by JSP, JSF etc.
I did this before simpleorm 3, but had to throw away the code because
now with dataset, you cannot blindly create a record, populate it from a
map and then attach() it. You have to first create it with the pkeys,
then set the other fields.
So we can implement Map, except for the put part. I'm not sure JSP, etc.
don't depend on put not throwing UnsupportedException for put.
What I have now is a little helper method that does this :
public class DataSetHelper {
public static <RI extends SRecordInstance> RI putAll(SDataSet ds, Map
fm, SRecordMeta<RI> meta) {
final Logger logger = LoggerFactory.getLogger(DataSetHelper.class);
RI rinst = null;
Object[] keys = new Object[meta.getPrimaryKeys().length];
int idx = 0;
SFieldScalar[] pkeys = meta.getPrimaryKeys();
boolean generated = false;
for (SFieldScalar pkey : pkeys) {
if (pkey.isGenerated()) {
if (pkeys.length > 1) {
// FIXME erreur
}
generated = true;
}
}
if ( ! generated) {
for (SFieldScalar pkey : meta.getPrimaryKeys()) {
keys[idx] = fm.getVal(pkey.getFieldName());
idx++;
}
rinst = ds.create(meta, keys);
}
else {
rinst = ds.createWithNullKey(meta);
}
for (SFieldScalar fld : meta.getAllScalarFields()) {
if ( ! fld.isPrimary()) {
rinst.setObject(fld, fm.get(fld.getFieldName()), false);
}
}
return rinst;
}
> I also want SConnections be able to be created by connections as well
> as or instead of DataSets as had been requested.
Why not... (I personnaly don't need that, but have seen someone wanted
it)
Regards,
Franck
------------------------------------
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/