-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: exception.SQLGrammarException: could not load entity
PostPosted: Fri Apr 07, 2006 6:17 pm 
Newbie

Joined: Fri Apr 07, 2006 5:30 pm
Posts: 4
Location: Buenos Aires
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

hello, i am experiencing a problem:
"org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]"

What is it?

Hibernate version:
3.1.1

Mapping documents:

“PersonaBO.hbm.xml”

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="vista.PersonaBO" table="persons">
<id name="id" type="integer" column="id" unsaved-value="-1">
<generator class="identity"/>
</id>
<property name="nombre"
column="nombre"
type="string"/>
<property name="apellido"
column="apellido"
type="string"/>
<property name="edad"
column="edad"
type="integer"/>
<property name="estadoCivil"
column="estadoCivil"
type="string"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

session = sessionFactory.openSession();
personaBO = (PersonaBO)session.get(PersonaBO.class,id1);
session.close();

Full stack trace of any exception that occurs:
javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.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(DatastoreException.java:28)
SearchPersonAction3.execute(SearchPersonAction3.java:67)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.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(DatastoreException.java:28)
PersonsManager2.getPersona(PersonsManager2.java:40)
SearchPersonAction3.execute(SearchPersonAction3.java:38)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.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.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
PersonsManager2.getPersona(PersonsManager2.java:33)
SearchPersonAction3.execute(SearchPersonAction3.java:38)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Name and version of the database you are using:
MySQL 5.0

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

...and i have got
- Tomcat 5.5.12
- mysql-connector-java-3.0.11-stable-bin.jar
- the files "persons.frm" and "db.opt" in web-inf/classes/personas

Bye, bye


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 09, 2006 10:19 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Is there a row in the "persons" table with id = 1?

If there is, can you post the generated SQL (show_sql="true")?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.