MyBatis example files

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

MyBatis example files

Steppenwulf
Hi,

I'm totally new to MyBatis. I'm using it with Spring, which I'm also
new to.

I'm not new to Java or SQL, however - if I can just figure out how
these config files and xml files need to look, and how they need to
interact with the Java classes or interfaces, I can get the rest.

I was wondering if there was any very simple example program -like a
Hello World for MyBatis - just 1 insert, and 1 result map, but
including all the actual xml and java files. If something like that
doesn't exist, I don't know if someone would be wiliing to publish a
few of their files? I think it would simplify things for us newbies,
as nothing similar seems to be in the documentation - and it is
tremendously annoying to not have something so simple.

I would especially appreciate something that combines Spring and
MyBatis.

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis example files

Guy Rouillier
On 10/17/2010 1:54 AM, Steppenwulf wrote:

> Hi,
>
> I'm totally new to MyBatis. I'm using it with Spring, which I'm also
> new to.
>
> I'm not new to Java or SQL, however - if I can just figure out how
> these config files and xml files need to look, and how they need to
> interact with the Java classes or interfaces, I can get the rest.
>
> I was wondering if there was any very simple example program -like a
> Hello World for MyBatis - just 1 insert, and 1 result map, but
> including all the actual xml and java files. If something like that
> doesn't exist, I don't know if someone would be wiliing to publish a
> few of their files? I think it would simplify things for us newbies,
> as nothing similar seems to be in the documentation - and it is
> tremendously annoying to not have something so simple.

Here is a simple command-line program you can build within Eclipse and
step through.  Not Spring, though - I don't use it.

See issue 78: http://code.google.com/p/mybatis/issues/detail?id=78

There are people on this list that have done a Spring-MyBatis
integration; I'm sure they will drop in.

--
Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis example files

Eduardo Macarron
Here you are :)
http://code.google.com/p/mybatis/source/browse/#svn/sub-projects/mybatis-spring/trunk/src/test/java/sample
http://code.google.com/p/mybatis/source/browse/#svn/sub-projects/mybatis-spring/trunk/src/test/resources/sample


On 17 oct, 08:12, Guy Rouillier <[hidden email]> wrote:

> On 10/17/2010 1:54 AM, Steppenwulf wrote:
>
>
>
>
>
> > Hi,
>
> > I'm totally new to MyBatis. I'm using it with Spring, which I'm also
> > new to.
>
> > I'm not new to Java or SQL, however - if I can just figure out how
> > these config files and xml files need to look, and how they need to
> > interact with the Java classes or interfaces, I can get the rest.
>
> > I was wondering if there was any very simple example program -like a
> > Hello World for MyBatis - just 1 insert, and 1 result map, but
> > including all the actual xml and java files. If something like that
> > doesn't exist, I don't know if someone would be wiliing to publish a
> > few of their files? I think it would simplify things for us newbies,
> > as nothing similar seems to be in the documentation - and it is
> > tremendously annoying to not have something so simple.
>
> Here is a simple command-line program you can build within Eclipse and
> step through.  Not Spring, though - I don't use it.
>
> See issue 78:http://code.google.com/p/mybatis/issues/detail?id=78
>
> There are people on this list that have done a Spring-MyBatis
> integration; I'm sure they will drop in.
>
> --
> Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis example files

Steppenwulf
In reply to this post by Guy Rouillier
Thanks a ton for the quick reply - this helps a lot. I'll try and use
it tomorrow.

I have gone through it quickly, though, and I had 3 quick questions:

1. I notice this is all using Ibatis 3, but I am using MyBatis. I
understand the code is about the same, but how would I need to change
the xml files - for instance the following header:

<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
                "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">

2. I understand the ContactMapper.xml, which works with the
ContactMapper interface, but why is there a BossMapper.xml? What
interface does it work with?

3. What does the Ibator config do? I didn't see it in the MyBatis
documentation.

Thanks again!

On Oct 17, 2:12 am, Guy Rouillier <[hidden email]> wrote:

> On 10/17/2010 1:54 AM, Steppenwulf wrote:
>
>
>
>
>
> > Hi,
>
> > I'm totally new to MyBatis. I'm using it with Spring, which I'm also
> > new to.
>
> > I'm not new to Java or SQL, however - if I can just figure out how
> > these config files and xml files need to look, and how they need to
> > interact with the Java classes or interfaces, I can get the rest.
>
> > I was wondering if there was any very simple example program -like a
> > Hello World for MyBatis - just 1 insert, and 1 result map, but
> > including all the actual xml and java files. If something like that
> > doesn't exist, I don't know if someone would be wiliing to publish a
> > few of their files? I think it would simplify things for us newbies,
> > as nothing similar seems to be in the documentation - and it is
> > tremendously annoying to not have something so simple.
>
> Here is a simple command-line program you can build within Eclipse and
> step through.  Not Spring, though - I don't use it.
>
> See issue 78:http://code.google.com/p/mybatis/issues/detail?id=78
>
> There are people on this list that have done a Spring-MyBatis
> integration; I'm sure they will drop in.
>
> --
> Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis example files

Onkar
On Oct 17, 12:09 pm, Steppenwulf <[hidden email]> wrote:

> Thanks a ton for the quick reply - this helps a lot. I'll try and use
> it tomorrow.
>
> I have gone through it quickly, though, and I had 3 quick questions:
>
> 1. I notice this is all using Ibatis 3, but I am using MyBatis. I
> understand the code is about the same, but how would I need to change
> the xml files - for instance the following header:
>
> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
>                 "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">

Refer to point 5 on page http://code.google.com/p/mybatis/wiki/DocIbatis2MyBatis
That is probably the only change you will need.

> 2. I understand the ContactMapper.xml, which works with the
> ContactMapper interface, but why is there a BossMapper.xml? What
> interface does it work with?

I haven't looked at the code. So can't answer that.

> 3. What does the Ibator config do? I didn't see it in the MyBatis
> documentation.

Ibator is a tool to create ibatis artifacts from a DB schema. Check
http://ibatis.apache.org/docs/tools/ibator/. You will probably not
need it.


Onkar
Reply | Threaded
Open this post in threaded view
|

Re: MyBatis example files

Jeff Butler
Here's the new page for the MyBatis code generator (formally Ibator):

http://code.google.com/p/mybatis/wiki/Generator

Jeff Butler


On Mon, Oct 18, 2010 at 8:46 AM, Onkar <[hidden email]> wrote:

> On Oct 17, 12:09 pm, Steppenwulf <[hidden email]> wrote:
>> Thanks a ton for the quick reply - this helps a lot. I'll try and use
>> it tomorrow.
>>
>> I have gone through it quickly, though, and I had 3 quick questions:
>>
>> 1. I notice this is all using Ibatis 3, but I am using MyBatis. I
>> understand the code is about the same, but how would I need to change
>> the xml files - for instance the following header:
>>
>> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
>>                 "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
>
> Refer to point 5 on page http://code.google.com/p/mybatis/wiki/DocIbatis2MyBatis
> That is probably the only change you will need.
>
>> 2. I understand the ContactMapper.xml, which works with the
>> ContactMapper interface, but why is there a BossMapper.xml? What
>> interface does it work with?
>
> I haven't looked at the code. So can't answer that.
>
>> 3. What does the Ibator config do? I didn't see it in the MyBatis
>> documentation.
>
> Ibator is a tool to create ibatis artifacts from a DB schema. Check
> http://ibatis.apache.org/docs/tools/ibator/. You will probably not
> need it.
>
>
> Onkar