Buenas.....al ejecutar una aplicaciòn (con el tomcat) que usa hibernate - struts, la cual debe conectarse a mySQL, me aparece:
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
PersonaBO.java es un java-bean
La pila de errores completa es:
type Informe de Excepción
mensaje
descripción El servidor encontró un error interno () que hizo que no pudiera rellenar este requerimiento.
excepción
javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processE xception(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
causa raíz
exceptions.DatastoreException
exceptions.DatastoreException.datastoreError(Datas toreException.java:28)
SearchPersonAction3.execute(SearchPersonAction3.ja va:67)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
causa raíz
exceptions.DatastoreException
exceptions.DatastoreException.datastoreError(Datas toreException.java:28)
PersonsManager2.getPersona(PersonsManager2.java:40 )
SearchPersonAction3.execute(SearchPersonAction3.ja va:38)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
causa raíz
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.java:65)
org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.loadEntity(Loader.java :1799)
org.hibernate.loader.entity.AbstractEntityLoader.l oad(AbstractEntityLoader.java:93)
org.hibernate.loader.entity.AbstractEntityLoader.l oad(AbstractEntityLoader.java:81)
org.hibernate.persister.entity.AbstractEntityPersi ster.load(AbstractEntityPersister.java:2730)
org.hibernate.event.def.DefaultLoadEventListener.l oadFromDatasource(DefaultLoadEventListener.java:36 5)
org.hibernate.event.def.DefaultLoadEventListener.d oLoad(DefaultLoadEventListener.java:346)
org.hibernate.event.def.DefaultLoadEventListener.l oad(DefaultLoadEventListener.java:123)
org.hibernate.event.def.DefaultLoadEventListener.p roxyOrLoad(DefaultLoadEventListener.java:177)
org.hibernate.event.def.DefaultLoadEventListener.o nLoad(DefaultLoadEventListener.java:87)
org.hibernate.impl.SessionImpl.fireLoad(SessionImp l.java:889)
org.hibernate.impl.SessionImpl.get(SessionImpl.jav a:826)
org.hibernate.impl.SessionImpl.get(SessionImpl.jav a:819)
PersonsManager2.getPersona(PersonsManager2.java:33 )
SearchPersonAction3.execute(SearchPersonAction3.ja va:38)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
-----------------------------------
“PersonaBO.hbm.xml”
<?xml version=\"1.0\"?>
<!-- <!DOCTYPE hibernate-mapping PUBLIC
\"-//Hibernate/Hibernate Mapping DTD 2.0//EN\"
\"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd\"> -->
<hibernate-mapping>
<class name=\"vista.PersonaBO\" table=\"persons\">
<id name=\"id\" column=\"id\" type=\"java.lang.Integer\" unsaved-value=\"null\">
<generator class=\"native\"/>
</id>
<property name=\"nombre\" >
<property name=\"apellido\" >
<property name=\"edad\">
<property name=\"estadoCivil\" >
</class>
</hibernate-mapping>
---------------------------------------
“hibernate.cfg.xml”
<?xml version=\'1.0\' encoding=\'utf-8\'?>
<!DOCTYPE hibernate-configuration
PUBLIC \"-//Hibernate/Hibernate Configuration DTD//EN\"
\"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">
<hibernate-configuration>
<session-factory>
<property name=\"connection.driver_class\">com.mysql.jdbc.Dr iv er</property>
<property name=\"connection.url\">jdbc:mysql://localhost/personas</property>
<property name=\"connection.username\">root</property>
<property name=\"connection.password\">flor</property>
<property name=\"dialect\">net.sf.hibernate.dialect.MySQLDia le ct</property>
<property name=\"use_outer_join\">true</property>
<property name=\"transaction.factory_class\">net.sf.hibernat e. transaction.JDBCTransactionFactory</property>
<property name=\"show_sql\">true</property>
<!-- Mapping files -->
<mapping resource="vista\PersonaBO.hbm.xml\"/>
</session-factory>
</hibernate-configuration>
------------
\"PersonsManager2.java\"
\"AQUÌ USO HQL\"
public class PersonsManager2 implements IManejadorPersonas
{
SessionFactory sessionFactory = null;
public PersonsManager2()throws DatastoreException
{
init();
}
public PersonaBO getPersona(String id1)throws DatastoreException
{
PersonaBO personaBO = null;
Session session = null;
try
{
session = sessionFactory.openSession();
personaBO = (PersonaBO)session.get(PersonaBO.class,id1);
session.close();
}catch (Exception ex)
{
ex.printStackTrace();
throw DatastoreException.datastoreError(ex);
}
return personaBO;
}
private void init()throws DatastoreException
{
try
{
sessionFactory=new Configuration().configure().buildSessionFactory();
}catch(Exception ex){
throw DatastoreException.datastoreError(ex);
}
}
}
-------------------
PersonaBO.class està en web-inf/classes/vista
Los archivos de la base de datos estàn estàn en: web-inf/classes/personas
----------
BaseBussinessObject es java-bean y es el padre de PersonaBO
\"BaseBussinessObject.java\"
package vista;
import java.io.*;
abstract public class BaseBussinessObject implements Serializable
{
private Integer id;
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id=id;
}
}
------------------------
\"PersonaBO.java\"
package vista;
public class PersonaBO extends BaseBussinessObject
{
private String nombre;
private String apellido;
private Integer edad;
private String estadoCivil;
public PersonaBO(){
super();
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public Integer getEdad() {
return edad;
}
public void setEdad(Integer edad) {
this.edad = edad;
}
public String getEstadoCivil() {
return estadoCivil;
}
public void setEstadoCivil(String estadoCivil) {
this.estadoCivil = estadoCivil;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
}
Realmente no me doy cuenta què tengo que hacer.....serà el hibernate.cfg.xml o alguna ubicaciòn erronea en particular de algùn archivo?
Gracias y Saludos a todos