The three names have to match:
- interface = com.enlliance.inventory.mappers.SettingMapper.class
- mapper file = /com/enlliance/inventory/mappers/SettingMapper.xml
- mapper namespace = com.enlliance.inventory.mappers.SettingMapper
If they don't match, it won't work.
Larry
Josh I have the same problem.
# My mapper interface
public interface UserInfoMapper {
public UserInfo getUserInfoBySnb(String snb);
public UserInfo getAllUserInfoBySnb(String snb);
public UserInfo getUserInfoByImsi(String imsi);
}
# Then my datasourceContext.xml
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="is.simnn.act.web.ngs.mappers" />
</bean>
# My UserInfoMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="is.simnn.act.web.ngs.mappers.UserInfoMapper">
<select id="getUserInfoBySnb" parameterType="string"
resultType="userInfo">
SELECT
port.snb,
port.timestamp,
port.user_type,
port.real_exch,
port.act_exch,
port.dev_type,
port.rc
FROM
port
WHERE
port.snb = #{snb}
</select>
<select id="getAllUserInfoBySnb" parameterType="string"
resultType="userInfo">
SELECT
p.snb,
p.real_exch,
p.act_exch,
p.user_type,
p.dev_type,
p.dev_number,
p.main_number,
p.ea_int,
p.ea_nat,
p.TIMESTAMP,
p.timestamp_comp,
p.rc,
p.bsnb,
p.black,
p.out_go_num,
p.imsi,
p.subscr_type,
p.dual_main,
p.dual_sec,
p.sec_exchange,
p.special_scl,
p.name_of_user,
p.status_id,
p.category_id,
p.head_number,
p.status_id_tstamp,
ngs.subscr_subtype
FROM
port p inner join ngs_add_data ngs
ON ngs.snb = p.snb
WHERE
p.snb = #{snb}
</select>
<select id="getUserInfoByImsi" parameterType="string"
resultType="userInfo">
SELECT
snb,
timestamp,
user_type,
real_exch,
act_exch,
dev_type,
rc
FROM
port
WHERE
imsi = #{imsi} AND port.status_id = 1
</select>
</mapper>
# Here is my mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="lazyLoadingEnabled" value="false" />
</settings>
<typeAliases>
<typeAlias alias="userInfo"
type="is.simnn.act.web.ngs.domain.UserInfo" />
</typeAliases>
</configuration>
Do you see anything wrong with my configuration?
Thanks
Gunnlaugur
--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Mapped-Statements-collection-does-not-contain-value-tp2553948p2951798.html
Sent from the mybatis-user mailing list archive at Nabble.com.
Josh I have the same problem.
# My mapper interface
public interface UserInfoMapper {
public UserInfo getUserInfoBySnb(String snb);
public UserInfo getAllUserInfoBySnb(String snb);
public UserInfo getUserInfoByImsi(String imsi);
}
# Then my datasourceContext.xml
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="is.simnn.act.web.ngs.mappers" />
</bean>
# My UserInfoMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<mapper namespace="is.simnn.act.web.ngs.mappers.UserInfoMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="lazyLoadingEnabled" value="false" />
</settings>
<typeAliases>
<typeAlias alias="userInfo"
type="is.simnn.act.web.ngs.domain.UserInfo" />
</typeAliases>
</configuration>
Do you see anything wrong with my configuration?
Thanks
Gunnlaugur
--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Mapped-Statements-collection-does-not-contain-value-tp2553948p2951964.html
Christian
-----Message d'origine-----
De : mybati...@googlegroups.com [mailto:mybati...@googlegroups.com] De la part de gunnlaugursig
Envoyé : May-17-11 6:39 AM
À : mybati...@googlegroups.com
Objet : Re: Mapped Statements collection does not contain value ....
My problem was that I had my UserInfoMapper.xml under
src/main/resources/META-INF/is/siminn/act/web/ngs/mappers
The mapper file has to be in the same directory as the interface ie.
src/main/java/is/siminn/act/web/ngs/mappers
This solved it. But then another problem came up. For some reason one of the
selects from the mapper constantly returns NullPointerException
I've tested it using SQL Developer and it works fine but I have not found
the reason for it's failure.
--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Mapped-Statements-collection-does-not-contain-value-tp2553948p2956786.html
No, that's not right.
It must be in the same package, not the same directory. If you have
src/main/java and src/main/resources on the class path, then you'd
want this:
- src/main/java/is/siminn/act/web/ngs/mappers/UserInfoMapper.java
- src/main/resources/is/siminn/act/web/ngs/mappers/UserInfoMapper.xml
Then the namespace for the xml file would be
"is.siminn.act.web.ngs.mappers.UserInfoMapper".
Larry
--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Mapped-Statements-collection-does-not-contain-value-tp2553948p2956933.html
i should use this namespace for my mapper
"is.siminn.act.web.ngs.mappers.UserInfoMapper" but how should i register
this mapper at the configuration.xml file?
--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Mapped-Statements-collection-does-not-contain-value-tp2553948p3348269.html