You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Okan Çetin <ok...@gmail.com> on 2006/09/08 22:12:27 UTC
select statement problem
Hello;
I could not getting something from db. list object does not contain any
value. Do you have any idea ?
The code and xml map files:
1) Code
List list;
Reader reader = Resources.getResourceAsReader
("com/data/SqlMapConfig.xml");
SqlMapClient sqlMapper =
SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
//usr=(User)sqlMapper.queryForObject("selectAllUsers");
list=sqlMapper.queryForList("selectAllUsers");
2) User.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="User">
<!-- Use type aliases to avoid typing the full classname every time. -->
<typeAlias alias="User" type="com.domain.User"/>
<!-- Result maps describe the mapping between the columns returned
from a query, and the class properties. A result map isn't
necessary if the columns (or aliases) match to the properties
exactly. -->
<!-- <resultMap id="UserResult" class="User">
<result property="firstname" column="firstname"/>
</resultMap>
-->
<!-- Select with no parameters using the result map for Account class. -->
<select id="selectAllUsers" >
select firstname from PUBLIC.user
</select>
</sqlMap>
3) User.java
public class User {
private String firstname;
// getter, setter methods..
Thanks for reply.
--
~
otomatik oluşturuldu:
http://ocetin.net/log
http://linux.beykent.edu.tr
Re: select statement problem
Posted by Okan Çetin <ok...@gmail.com>.
On 9/9/06, Larry Meadors <lm...@apache.org> wrote:
>
> You do not have a resultClass in your <select> element.
Thanks a lot, it works (:
Larry
>
>
> On 9/8/06, Okan Çetin <ok...@gmail.com> wrote:
> > Hello;
> > I could not getting something from db. list object does not contain any
> > value. Do you have any idea ?
> > The code and xml map files:
> >
> > 1) Code
> >
> > List list;
> > Reader reader =
> > Resources.getResourceAsReader("com/data/SqlMapConfig.xml");
> > SqlMapClient sqlMapper =
> > SqlMapClientBuilder.buildSqlMapClient (reader);
> > reader.close();
> >
> > //usr=(User)sqlMapper.queryForObject("selectAllUsers");
> > list=sqlMapper.queryForList("selectAllUsers");
> >
> > 2) User.xml
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> >
> > <!DOCTYPE sqlMap
> > PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
> > "http://ibatis.apache.org/dtd/sql-map-2.dtd">
> >
> > <sqlMap namespace="User">
> >
> > <!-- Use type aliases to avoid typing the full classname every time.
> -->
> > <typeAlias alias="User" type="com.domain.User"/>
> >
> > <!-- Result maps describe the mapping between the columns returned
> > from a query, and the class properties. A result map isn't
> > necessary if the columns (or aliases) match to the properties
> > exactly. -->
> > <!-- <resultMap id="UserResult" class="User">
> > <result property="firstname" column="firstname"/>
> > </resultMap>
> > -->
> >
> > <!-- Select with no parameters using the result map for Account class.
> -->
> > <select id="selectAllUsers" >
> > select firstname from PUBLIC.user
> > </select>
> >
> > </sqlMap>
> >
> > 3) User.java
> >
> > public class User {
> > private String firstname;
> > // getter, setter methods..
> >
> > Thanks for reply.
> >
> > --
> > ~
> > otomatik oluşturuldu:
> > http://ocetin.net/log
> > http://linux.beykent.edu.tr
>
--
~
otomatik oluşturuldu:
http://ocetin.net/log
http://linux.beykent.edu.tr
Re: select statement problem
Posted by Larry Meadors <lm...@apache.org>.
You do not have a resultClass in your <select> element.
Larry
On 9/8/06, Okan Çetin <ok...@gmail.com> wrote:
> Hello;
> I could not getting something from db. list object does not contain any
> value. Do you have any idea ?
> The code and xml map files:
>
> 1) Code
>
> List list;
> Reader reader =
> Resources.getResourceAsReader("com/data/SqlMapConfig.xml");
> SqlMapClient sqlMapper =
> SqlMapClientBuilder.buildSqlMapClient (reader);
> reader.close();
>
> //usr=(User)sqlMapper.queryForObject("selectAllUsers");
> list=sqlMapper.queryForList("selectAllUsers");
>
> 2) User.xml
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <!DOCTYPE sqlMap
> PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
> "http://ibatis.apache.org/dtd/sql-map-2.dtd">
>
> <sqlMap namespace="User">
>
> <!-- Use type aliases to avoid typing the full classname every time. -->
> <typeAlias alias="User" type="com.domain.User"/>
>
> <!-- Result maps describe the mapping between the columns returned
> from a query, and the class properties. A result map isn't
> necessary if the columns (or aliases) match to the properties
> exactly. -->
> <!-- <resultMap id="UserResult" class="User">
> <result property="firstname" column="firstname"/>
> </resultMap>
> -->
>
> <!-- Select with no parameters using the result map for Account class. -->
> <select id="selectAllUsers" >
> select firstname from PUBLIC.user
> </select>
>
> </sqlMap>
>
> 3) User.java
>
> public class User {
> private String firstname;
> // getter, setter methods..
>
> Thanks for reply.
>
> --
> ~
> otomatik oluşturuldu:
> http://ocetin.net/log
> http://linux.beykent.edu.tr