On Sat, Aug 16, 2008 at 8:08 PM, Dominic Watson wrote:
> Sounds awesome ;)
It is pretty cool, and the annotation approach is very tempting.
There are so many ways to do it tho... and I'm seriously thinking a
modeling language is where it's really at, but, this is still way fun.
=]
> So in theory, CF could use Hibernate (when it releases that stuff in
> 9) to automatically parametise a query, with no extra work from the
> developer, ie. the developer just writes:
>
> <cfquery name="myQuery" datasource="myDs">
> SELECT foo FROM bar WHERE foobar = 4570
> </cfquery>
No, Hibernate is an ORM, so while you can create ad-hoc SQL queries (a
few nice ways of doing so, ta boot), the real power is in the
object-ness.
More like, to get all Bar objects with a foo ID of 4570 (:
var bar = createObject("component","den.foo.Bar");
bar.setFooID(4570);
allBarsWithFooID4570 = persisdanceService.queryByObject(bar);
Or you could load a specific object, or whatever. The focus is on the
objects, not the SQL.
What I've got makes it so you can add "named queries" in the object
metadata (which is basically plain old SQL).
FWIW, what you're suggesting (auto-parameter binding) is already
possible for POSQL (Plain Old SQL). Jochems points about ambiguous
functions non-withstanding.
You could probably stick a layer in a open-source CF engine that would
auto-bind 98% of stuff (assuming 98% of CF is plain old SQL queries,
vs. stored procedures). I don't know the powers of introspecting
stored procedures/functions, but I bet there are things you could do
that would take care of most of them too, if they aren't too fancy.
If it's all done with JDBC (can JDBC even introspect that good?) it's
cake... and I bet there are java libraries that you could tap for
dialect-specific stuff.
Maybe not tho.
Surely simple SQL like "SELECT foo FROM bar WHERE bar = #uh.someVar#"
could be automatically bound to the correct types with existing JDBC
introspection capabilities.
> Anyways, I'm not all that fussed by this being a possibility, just
> humouring an idea. Do you think this would be possible without any
> extra configuration from the dev?
Oh, you'd basically just point it at a DSN, as usual, but you'd be
dealing with objects instead of SQL for the most part.
> Can't wait to try your port of Hibernate for CF :)
I can send you a link to the subversion source, if you're curious, but
it's nothing you'd want to actually use yet. Everything is still
shifting... well, not *so* much now, but I make huge changes and
haven't solidified the API at all... basically I'm just organizing all
the separate parts I got going into something cohesive, and still
experimenting.
I need to do load testing of a couple of the ways I've tried to handle
the link between CF and Hibernate, and start solidifying the querying.
Streamline schema creating/updating.
And write a ton of tests. I should have been writing the tests all
along, but I wasn't sure if the idea would even pan out.
Bah. You live, you learn. Sometimes slowly, apparently. :-)
Andrew has an interesting idea... so far, I haven't been using
onMissingMethod stuff, just because it's only in CF8 (although one
could write something for 7 I reckon)-- but so far, the hibernate
stuff has only really worked in CF8, so, what the hell. :-)
It would be pretty easy to add myObject.findByFirstName('Andrew') to
what I've got.
But I'm worried about overhead, a little, which is why I need to start
load-testing ASAP.
Eh.
I have been really impressed with Hibernate. Good docs, lots of info.
Although, there are a lot of (pretty robust looking) Java ORM options
now, which makes me wonder, but anyways, hibernate is pretty pimp.
The auto-updating DB schema and whatnot, you know? Good stuff.
Been fun, even if there will probably be something much better in CF9. :-)
--
I'm building a contraption!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311135
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4