how can i get xml in simplest way from mybatis

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

how can i get xml in simplest way from mybatis

janak
i am new to mybatis pls help.
i have table user(id,userName,password,firstName,LastName).
my qry select * from user and have about 20,000 rows, i want to
convert result data to xml  using  List<userMaster>.
how can i do
Reply | Threaded
Open this post in threaded view
|

Re: how can i get xml in simplest way from mybatis

Clinton Begin
Administrator
XStream rules.

On Sat, Oct 23, 2010 at 1:40 PM, janak <[hidden email]> wrote:
i am new to mybatis pls help.
i have table user(id,userName,password,firstName,LastName).
my qry select * from user and have about 20,000 rows, i want to
convert result data to xml  using  List<userMaster>.
how can i do

Reply | Threaded
Open this post in threaded view
|

Re: how can i get xml in simplest way from mybatis

Larry Meadors
+1

On 10/23/10, Clinton Begin <[hidden email]> wrote:

> XStream rules.
>
> On Sat, Oct 23, 2010 at 1:40 PM, janak <[hidden email]> wrote:
>
>> i am new to mybatis pls help.
>> i have table user(id,userName,password,firstName,LastName).
>> my qry select * from user and have about 20,000 rows, i want to
>> convert result data to xml  using  List<userMaster>.
>> how can i do
>

--
Sent from my mobile device
Reply | Threaded
Open this post in threaded view
|

Re: how can i get xml in simplest way from mybatis

Simone Tripodi
In reply to this post by Clinton Begin
Hi Janak,
as Clinton suggested, once mapped the sql statement to your java
objects, you have to use an XML marshaller library to bind your domain
objects to XML. You have good choices (JAXB, Apache Betwixt) but it
seems XStream is the most efficient.
Good luck,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sat, Oct 23, 2010 at 9:55 PM, Clinton Begin <[hidden email]> wrote:

> XStream rules.
>
> On Sat, Oct 23, 2010 at 1:40 PM, janak <[hidden email]> wrote:
>>
>> i am new to mybatis pls help.
>> i have table user(id,userName,password,firstName,LastName).
>> my qry select * from user and have about 20,000 rows, i want to
>> convert result data to xml  using  List<userMaster>.
>> how can i do
>
Reply | Threaded
Open this post in threaded view
|

Re: how can i get xml in simplest way from mybatis

Clinton Begin
Administrator
As a historical reference... 

MyBatis used to have direct XML mapping.  But through my experience, I found that I always ended up mapping everything twice anyway.  It was really rare (if ever?) that I only wanted XML... I always seemed to want a richer domain mapping as well.  

And now, even if I do only want the XML, it's about as easy to create the XStream annotated domain class as it would have been to define the large XML result mapping. 

It was all a "smell" that indicated clearly that the XML mapping was happening at the wrong layer of the application stack (the persistence layer).

Thus, XML mapping was removed.

Cheers,
Clinton

On Sat, Oct 23, 2010 at 2:24 PM, Simone Tripodi <[hidden email]> wrote:
Hi Janak,
as Clinton suggested, once mapped the sql statement to your java
objects, you have to use an XML marshaller library to bind your domain
objects to XML. You have good choices (JAXB, Apache Betwixt) but it
seems XStream is the most efficient.
Good luck,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sat, Oct 23, 2010 at 9:55 PM, Clinton Begin <[hidden email]> wrote:
> XStream rules.
>
> On Sat, Oct 23, 2010 at 1:40 PM, janak <[hidden email]> wrote:
>>
>> i am new to mybatis pls help.
>> i have table user(id,userName,password,firstName,LastName).
>> my qry select * from user and have about 20,000 rows, i want to
>> convert result data to xml  using  List<userMaster>.
>> how can i do
>

Reply | Threaded
Open this post in threaded view
|

Re: how can i get xml in simplest way from mybatis

Simone Tripodi
Hi Clinton!
even if some of us (me included) would like to see that feature back
(mapping directly to XML without storing info in POJOs should be more
efficient), I've always had the feeling that it was a little out of
the main scope.

Moreover, since the internet formats proliferation is increasing day
by day - once upon a time XML, today REST services speak also JSON,
YAML, etc etc - and there are a lot of libraries to work with them, I
don't see the reason to support and maintain them in MyBatis.

I'm used to write REST services using JAX-RS spec and MyBatis,
delegating the different formats serialization to JAX-RS producers on
top of 3rd part frameworks, at level of design makes much more sense.

Have a nice weekend,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sat, Oct 23, 2010 at 10:34 PM, Clinton Begin <[hidden email]> wrote:

> As a historical reference...
> MyBatis used to have direct XML mapping.  But through my experience, I found
> that I always ended up mapping everything twice anyway.  It was really rare
> (if ever?) that I only wanted XML... I always seemed to want a richer domain
> mapping as well.
> And now, even if I do only want the XML, it's about as easy to create the
> XStream annotated domain class as it would have been to define the large XML
> result mapping.
> It was all a "smell" that indicated clearly that the XML mapping was
> happening at the wrong layer of the application stack (the persistence
> layer).
> Thus, XML mapping was removed.
> Cheers,
> Clinton
>
> On Sat, Oct 23, 2010 at 2:24 PM, Simone Tripodi <[hidden email]>
> wrote:
>>
>> Hi Janak,
>> as Clinton suggested, once mapped the sql statement to your java
>> objects, you have to use an XML marshaller library to bind your domain
>> objects to XML. You have good choices (JAXB, Apache Betwixt) but it
>> seems XStream is the most efficient.
>> Good luck,
>> Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Sat, Oct 23, 2010 at 9:55 PM, Clinton Begin <[hidden email]>
>> wrote:
>> > XStream rules.
>> >
>> > On Sat, Oct 23, 2010 at 1:40 PM, janak <[hidden email]> wrote:
>> >>
>> >> i am new to mybatis pls help.
>> >> i have table user(id,userName,password,firstName,LastName).
>> >> my qry select * from user and have about 20,000 rows, i want to
>> >> convert result data to xml  using  List<userMaster>.
>> >> how can i do
>> >
>
>