15/07/2011, 10:52
|
| | Fecha de Ingreso: septiembre-2009
Mensajes: 7
Antigüedad: 15 años, 4 meses Puntos: 0 | |
Respuesta: Problema con MyBatis/Spring AbstractActionBean
Código:
package backingbeans;
import java.io.Serializable;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.SimpleMessage;
abstract class AbstractActionBean implements ActionBean, Serializable {
private static final long serialVersionUID = -1767714708233127983L;
protected static final String ERROR = "/WEB-INF/jsp/common/Error.jsp";
protected transient ActionBeanContext context;
protected void setMessage(String value) {
context.getMessages().add(new SimpleMessage(value));
}
public ActionBeanContext getContext() {
return context;
}
public void setContext(ActionBeanContext context) {
this.context = context;
}
}
UserLogingBean
Código:
package backingbeans;
import java.io.Serializable;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.SimpleMessage;
abstract class AbstractActionBean implements ActionBean, Serializable {
private static final long serialVersionUID = -1767714708233127983L;
protected static final String ERROR = "/WEB-INF/jsp/common/Error.jsp";
protected transient ActionBeanContext context;
protected void setMessage(String value) {
context.getMessages().add(new SimpleMessage(value));
}
public ActionBeanContext getContext() {
return context;
}
public void setContext(ActionBeanContext context) {
this.context = context;
}
}
ConnectionFactory
Código:
package com.appweb.listeners;
import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
public class ConnectionFactory {
private static SqlSessionFactory sqlMapper;
private static Reader reader;
static{
try{
reader = Resources.getResourceAsReader("configuration.xml");
sqlMapper = new SqlSessionFactoryBuilder().build(reader);
}catch(Exception e){
e.printStackTrace();
}
}
public static SqlSessionFactory getSession(){
return sqlMapper;
}
}
UsuariosMapper
Código:
package com.appweb.mappers;
import java.util.List;
import com.appweb.objects.Usuarios;
public interface UsuariosMapper {
List<Usuarios> selectUsuarios();
}
UsuariosMapper.xml
Código:
package com.appweb.mappers;
import java.util.List;
import com.appweb.objects.Usuarios;
public interface UsuariosMapper {
List<Usuarios> selectUsuarios();
}
Usuarios
Código:
package com.appweb.objects;
public class Usuarios {
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column usuarios.usuario
* @mbggenerated Wed Jul 13 17:33:52 CEST 2011
*/
private String usuario;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column usuarios.password
* @mbggenerated Wed Jul 13 17:33:52 CEST 2011
*/
private String password;
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column usuarios.usuario
* @return the value of usuarios.usuario
* @mbggenerated Wed Jul 13 17:33:52 CEST 2011
*/
public String getUsuario() {
return usuario;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column usuarios.usuario
* @param usuario the value for usuarios.usuario
* @mbggenerated Wed Jul 13 17:33:52 CEST 2011
*/
public void setUsuario(String usuario) {
this.usuario = usuario;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column usuarios.password
* @return the value of usuarios.password
* @mbggenerated Wed Jul 13 17:33:52 CEST 2011
*/
public String getPassword() {
return password;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column usuarios.password
* @param password the value for usuarios.password
* @mbggenerated Wed Jul 13 17:33:52 CEST 2011
*/
public void setPassword(String password) {
this.password = password;
}
}
configuration.xml
Código:
<?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>
<properties resource="database.properties"/>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${database.driver}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/appweb/mappers/UsuariosMapper.xml"/>
</mappers>
</configuration>
UsuariosSvc.java
Código:
<?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>
<properties resource="database.properties"/>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${database.driver}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/appweb/mappers/UsuariosMapper.xml"/>
</mappers>
</configuration>
|