This post originated from an RSS feed registered with Java Buzz
by Brian McCallister.
Original Post: jDBI 2.0pre1
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Pushed jDBI 2.0pre1 last
night. This is very much an ongoing development branch -- not many
docs, not all the sugary features of 1.X (Spring TX integration, the
magic configuration detection, etc), but it has some major features
that just aren't doable under the 1.X design, like much more
explicit control over things when you need it, while still providing
the higher level functions when you don't -- and the ability to mix
them pretty willy-nilly.
Rather than C&P lots of code here, I'll reference the test cases
to demonstrate stuff =)
public void testIteratorBehavior3() throws Exception {
h.insert("insert into something (id, name) values (?, ?)", 1, "keith");
h.insert("insert into something (id, name) values (?, ?)", 2, "keith");
int count = 0 ;
for (Something s : h.createQuery("select * from something order by id").map(Something.class))
{
count++;
assertEquals("keith", s.getName());
}
assertEquals(2, count);
}
Much more powerful statement
rewriting capabilites. The rules (and rewriter) from 1.X is
the default, but you can add additional macro capabilities
pretty easily, say something like: select
{org.skife.jdbi.Something} from something which will look
up writeable javabeans properties on Something and
put this in by name. That is not to say jDBI does strong o/r m,
but that it is trivial to add ActiveRecord style
auto-mapping (not its querying stuff, or tight integration with
the stack, am not tring to bring down the wrath of the railzors
(which I probably count as, so, umh, hmm)) in a typed manner
(and without the dreaded select * from something).
The 2.0 branch (trunk really)
keeps all the easy to use batching, prepared batching,
scripting, externalized statements, etc. Just adds better hooks
into the innards, and makes more fine grained stuff easier,
which is awfully important to be able to drill into. Once again,
jDBI is not a JDBC abstraction library, it is a JDBC convenience
library -- optimized for people, not driver writers!
Anyway, have fun! and let us know if things
break, could be better, are bass ackwards, or whatnot!