Por que será que dá exceção dizendo que a tabela (tabela usuario) não está mapeada no Hibernate (versão 3.2.1) se ela está mapeada?
Exceção quando faz a Query:
usuario is not mapped [From usuario]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<schema-selection match-catalog="transport"/>
<table-filter match-name="clientes"/>
<table-filter match-name="endereco"/>
<table-filter match-name="usuario"/>
</hibernate-reverse-engineering>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="transys.pojo.Usuario" table="usuario" catalog="transport">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<property name="login" type="string">
<column name="login" length="20" />
</property>
<property name="senha" type="string">
<column name="senha" length="100" />
</property>
<property name="nomeReal" type="string">
<column name="nome_real" length="50" />
</property>
<property name="email" type="string">
<column name="email" length="150" />
</property>
<property name="nivel" type="java.lang.Short">
<column name="nivel" />
</property>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/transport</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">SENHA</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="transys/pojo/Clientes.hbm.xml"/>
<mapping resource="transys/pojo/Usuario.hbm.xml"/>
<mapping resource="transys/pojo/Endereco.hbm.xml"/>
</session-factory>
</hibernate-configuration>
private void buildUsuarioOptions() {
List<Usuario> usuarioList = null;
try {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
org.hibernate.Transaction tx = session.beginTransaction();
org.hibernate.Query q = session.createQuery("From usuario");
//org.hibernate.Query q = session.createSQLQuery("SELECT * FROM usuario");
usuarioList = (List<Usuario>) q.list();
} catch (Exception e) {
info("Erro: "+e.getMessage());
e.printStackTrace();
}
this.listaUsuarioOptions = new Option[usuarioList.size()];
int i = 0;
for (Usuario item : usuarioList) {
info("Usuario: "+item.getLogin());
Option opt = new Option(item.getId(), item.getLogin());
this.listaUsuarioOptions[i++] = opt;
}
}
Alguém saberia me dar uma dica do que estou fazendo errado? Estou iniciando em Hibernate e achava que estava tudo certo mas esta dando esse erro.
Obrigado.