Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for gt.edu.uvg.model.beans.student.find

479 views
Skip to first unread message

Jorge Estuardo Polanco Cortez

unread,
Mar 14, 2011, 2:28:46 PM3/14/11
to mybatis-user
Hello, I have a problem and I don't know how to solve.

Thanks for the help

When I try run the main method, throw this Exception

Exception in thread "main"
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause:
java.lang.IllegalArgumentException: Mapped Statements collection does
not contain value for gt.edu.uvg.model.beans.student.find
### Cause: java.lang.IllegalArgumentException: Mapped Statements
collection does not contain value for
gt.edu.uvg.model.beans.student.find
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
8)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
77)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
69)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:
40)
at gt.edu.uvg.itl.daos.ibatis.IbatisStudentDAO.find(Unknown
Source)
at junit.Main.main(Main.java:43)
Caused by: java.lang.IllegalArgumentException: Mapped Statements
collection does not contain value for
gt.edu.uvg.model.beans.student.find
at org.apache.ibatis.session.Configuration
$StrictMap.get(Configuration.java:593)
at
org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:
393)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
74)
... 4 more
Java Result: 1

****************************************************
public class Person implements Serializable {
protected Integer code;
protected String name;
protected String lastName;
protected List phones;

public Integer getCode() {
return code;
}

public void setCode(Integer code) {
this.code = code;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public List getPhones() {
return phones;
}

public void setPhones(List phones) {
this.phones = phones;
}
}
****************************************************
public class Student extends Person {
private String studentId;

public String getStudentId() {
return studentId;
}

public void setStudentId(String studentId) {
this.studentId = studentId;
}
}
****************************************************
public interface PersonDAO {

public Person find(Integer code) throws Exception;
public Person find(String username) throws Exception;
public Email getPrincipalEmail(String username) throws Exception;

}
****************************************************
public interface StudentDAO extends PersonDAO {
public Student find(String studentId) throws Exception;
}
****************************************************
public class IbatisPersonDAO implements PersonDAO {
public Person find(Integer code) throws Exception {
SqlSession session = null;
Person found;
try {
logger.info("public Person find(Integer code) throws
Exception");
session =
IbatisUtil.getSessionFactory(IbatisUtil.FUNUDV_DB).openSession();
logger.info("Code to find " + code);
found = (Person)
session.selectOne("gt.edu.uvg.model.beans.Person.find", code);
logger.info("Object " + ((found != null)?("result " +
found):(" NOT FOUND ")));
session.commit();
} catch (Exception exception) {
throw exception;
} finally {
if (session != null) {
session.close();
}
}
return found;
}
public Person find(String username) throws Exception {
SqlSession session = null;
Person found;
try {
UserDAO userDAO =
DAOFactory.getDAOFactory(DAOFactory.IBATIS).getUserDAO();
User user = userDAO.findByUsername(username);

logger.info("public Person find(String username) throws
Exception");
session =
IbatisUtil.getSessionFactory(IbatisUtil.FUNUDV_DB).openSession();
logger.info("username to find " + username);
found = (Person)
session.selectOne("gt.edu.uvg.model.beans.Person.find",
Integer.parseInt(user.getPersonCode()));
logger.info("Object " + ((found != null)?("result " +
found):(" NOT FOUND ")));
session.commit();
} catch (Exception exception) {
throw exception;
} finally {
if (session != null) {
session.close();
}
}
return found;
}
public Email getPrincipalEmail(String username) throws Exception {
logger.info("public Email getPrincipalEmail(String username)
throws Exception");
Email email = null;
Person person = find(username);
logger.info("if (person != null)");
if (person != null) {
List emails = person.getEmails();
logger.info("email list size " +
person.getEmails().size());
BeanPropertyValueEqualsPredicate clousure = new
BeanPropertyValueEqualsPredicate("primary",Boolean.TRUE);
email = (Email) CollectionUtils.find(emails, clousure);
logger.info("Primary email " + ((email != null)?("result "
+ email):(" NOT FOUND ")));
}
return email;
}
}
****************************************************
public class IbatisStudentDAO extends IbatisPersonDAO implements
StudentDAO {
@Override
public Student find(String studentId) throws Exception {
SqlSession session = null;
Student found;
try {
logger.info("public Student find(String studentId) throws
Exception");
session =
IbatisUtil.getSessionFactory(IbatisUtil.FUNUDV_DB).openSession();
logger.info("student to find " + studentId);
found = (Student)
session.selectOne("gt.edu.uvg.model.beans.student.find", studentId);
logger.info("Object " + ((found != null)?("result " +
found):(" NOT FOUND ")));
session.commit();
} catch (Exception exception) {
throw exception;
} finally {
if (session != null) {
session.close();
}
}
return found;
}
}
Reply all
Reply to author
Forward
0 new messages