On Tue, 25 Jan 2005 09:48:20 +1100, Gavin King <[EMAIL PROTECTED]> wrote:
Guys, please review:
org.hibernate.test.sql.SQLQueryTest.testSQLQueryInterface()
It demonstrates the new SQLQuery interface, which will replace the horrible createSQLQuery() methods.
It for sure looks better.
Let me know what you think. I'm not 100% sold on it yet.
List l = s.createSQLQuery("select {org.*}, {emp.*}, emp.regionCode from organization org left outer join employment emp on org.id = emp.employer")
.addEntity("org", Organization.class)
.addJoin("emp", "org.employments")
.addScalar("regionCode", Hibernate.STRING)
.list();
Just dumping thoughts on the above:
addEntity is better than setEntity (which we IM'ed about),
but is "add" the right word/concept for the user ? Would mapEntity, aliasEntity, bindEntity be better ?
addJoin - is that a new feature or did that come in there together with load-collection and i've just been blind ?
addScalar - ok, any thoughts on how this "scales" up to handling compositeusertypes ?
The suggested xml version is something like: <return-scalar type="MonetaryAmount"> <column-alias name="c1"/> <column-alias name="c2"/> </return-scalar>
in the API that would be something like:
.addScalar(new String[] { "c1", "c2" }, Hibernate.custom(MonetaryAmmount.class)) or ?
Then there is the whole sequencing of the resulting Object[] ?
If we want to keep the strict ordering scalar-first, entities-last then I would
like to force the users to obey to this in their code. This could be done by
simply having addScalar check that no entities have been added - and otherwise
throw an exception telling about the sequence needed ?
-max
------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel