Hello,
Michael Moossen NO TENGO! . wrote:
Hi, all
first of all, i want to give my solution for counting the number of rows with a Criteria, a question i saw no remember where, may be in the wiki?
take a not null column (may be a pk column), add the condition: row is not null and add a select column count(*)
it works, but i think it will be slower than a count without the condition, depending of the db engine.
now, after spending several days of works integrating my app with torque, i am really disappointed with the restrictions of torque... i mean, it is normal that any app has restrictions, but they should be well documented. in torque's docs i have not seen any word speaking about the restriction to single column pk tables.
I don't think torque is limited to single column primary key, you can define more columns as primary keys but you need to specify idMethod none
since only you know how to generate these primay key values (most probably they are foreign keys to another table)
the criteria how-to just speaks about a limitation for outer joins.. but it can not handle conditions splits through several columns, like:
id is not null or (date1 < today and date2 > today)
Are you sure? Have you seen Criteria.Criterion?? (http://db.apache.org/torque/criteria-howto.html)
another suggestions to the developers:
- id_broker seems to be a nice tool but it is restricted to single column pks... think about a Invoice with pk (year, month, nr) where the nr has to be autoincremented but restarted each month, my solution is prior to insert to select max(id) where year=.. and month=.. and increment it, which can be generalised.
Criteria has to be improved:
- why to use two criterias for updates, just add this funcionallity to Criteria by some set(column, value) methods and that is.
- i think a criteria intention should be declared explicitly, via an abtract factory and/or a enum like:
CriteriaFactory.getNewSelectCriteria()
or
new Criteria(Criteria.SELECT)
- i am a fan of prepared statements (normal statements need formatting and escaping, it is simplier and more secure to encapsulate a java.util.Date into a java.sql.TimeStamp than to format it, where you have to take care of the db engine date format), torque uses PS, but i have seen a case where not, don't remember where...
- when you support more general pks, it should be nice when Criteria allows to specify a join (over several fields), and other things, just given a PrimaryKey object (which should refer to several columns, of course)
- now i am fixing some essential things providing facades for Criteria and BasePeer and Query, but it was not easy sence SqlEnum is package private...
- i hope next releases fix some limitations, but it seems to be hard, because they affect the core design... but at least guys, put this in the documentation as visible as posible...
- i think it is also a good idea to keep the project up to date with java versions, to use log4j has no sence since java 1.4 includes the logging API. and to include a jar for just use one or two methods of StringUtils, is not worth...
finally, thanx for all the effort for doing torque possible and stay working on it.... i am still using most torque's capabilities and more important i got tons of good ideas from it..
best regards, michael
Best regards, Andras.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]