The development stack is stripes+guice+mybatis+hsqldb+junit4+mockito.
It's using a couple of new features:
- package level configuration by convention available in the
programmatic config API
- and the new SqlSessionManager (available in the current snapshot
and will be in the next release)
Feel free to check it out and build the war file. Only have to drop
it into any container and you are good to go. We have changed it from
pgSql to an in memory DB (hsqldb) to make life even easier.
More to come! When I get a chance I will add a few more simple table
to show joins and other common features.
MyBatis Team
The stack trace shows that it's here:
org.sample.mybatis.mappers.ContactMapperTest.crudOperations(ContactMapperTest.java:46)
That's the insert, but I set everything except the id which we're
getting in the sql map...unless Nathan changed it to work with hsqldb.
Which he did...sunuva. :-)
OK, so you'll need to change that for Oracle to look something like this:
<insert id="insert">
<selectKey resultType="integer" order="BEFORE" keyProperty="id">
select ids.nextval as value from dual
</selectKey>
insert into contact (
id, lastName, firstName, phone, email
) values (
#{id}, #{lastName}, #{firstName}, #{phone}, #{email}
)
</insert>
Try that, and see if it works. It should. :-D
Larry
As much as I loathe JNDI, it's kind of popular with some people.
Larry
http://code.google.com/p/mybatis/wiki/Logging
Might it be possible to factor Guice and Stripes out? I see Stripes
is more of a UI toolkit, which isn't what I'm looking at, but I'm not
familiar with Guice and am wary of trying to learn two significantly
new and different techniques at once.
It's hard for me to tell which parts of the code Guice is handling and
which parts MyBatis is handling, while I'm interested in implementing
MyBatis alone.
Thanks...
Rob
Sure - what is it you're trying to do or understand?
What kind of app are you looking for?
Larry
Thanks! The Guice stuff is a different paradigm than I'm used to; I
just need to wrap my head around the implementation of MyBatis. An
example that grabs data out of a single table and drops it into an
array of objects would probably be enough for me to run with. I
unfortunately got lost in the Guice stuff when I looked at your
example, not knowing which parts were Guice-isms and which parts were
MyBatis requirements.
> What kind of app are you looking for?
I'm writing a GWT app, but the DAO layer is just regular Java. The
only external libraries I'm using are JUnit, Mockito, GWT (not in the
DAO layer), and of course MyBatis. Anything from a simple servlet to
something that spits table data out on the console would work if it's
not using cool new stuff like Guice. :-)
Thanks!
Rob
I can't tell you the last time I actually had to write a pure servlet.
Sound like you are asking for a simple Main.java which would do a
query and maybe some updates/inserts/deletes.
I can respect that, and definitely appreciate the effort put in to the
example that is out there.
> I can't tell you the last time I actually had to write a pure servlet.
I wrote one a few months ago. Count your blessings.
> Sound like you are asking for a simple Main.java which would do a
> query and maybe some updates/inserts/deletes.
Exactly; I just need a basic example of MyBatis. I don't need the
rest of the cool stuff, which unfortunately obfuscated the simplicity
of MyBatis /for me/...
Anything you can do is appreciated. Worst case, I'll just have to
learn Guice, too, which would be an unfortunate delay but might be
beneficial in the long run.
Rob
Larry
PS: Sorry about having to write a servlet. That sucks. :-)
I have a basic single file Java command line program that I use to test
things out with iBATIS. I'd gladly share it; where can I post it? I
put some code up on the wiki whiteboard a couple months ago (Oracle
stored proc example, which others have been asking for here), but that
appears to have been wiped clean. So, where do user contributions go now?
--
Guy Rouillier
Sorry for the long delay, but I've finally implemented a version of the
contact_manager sample application that is a simple command line program
without all the webapp wrapping. I also unraveled some of the
directories as I didn't think the deep nesting was necessary. I'm going
to submit this example as mybatis_contact_manager_cli. Hopefully it
will show up in the repository soon.
When I have time in the next couple days, I'll add a simple example of
calling an Oracle stored procedure.
--
Guy Rouillier
See issue 78: http://code.google.com/p/mybatis/issues/detail?id=78
--
Guy Rouillier
[1] http://mybatis.googlecode.com/svn/sub-projects/mybatis-guice/trunk
http://people.apache.org/~simonetripodi/
http://www.99soft.org/