-->
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.  [ 5 posts ] 
Author Message
 Post subject: exception.SQLGrammarException: could not load an entity
PostPosted: Sat Apr 08, 2006 6:11 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:
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):

Hibernate: select personabo0_.id as id0_0_, personabo0_.nombre as nombre0_0_, personabo0_.apellido as apellido0_0_, personabo0_.edad as edad0_0_, personabo0_.estadoCivil as estadoCi5_0_0_ from persons5 personabo0_ where personabo0_.id=?
18:46:27,984 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 07001
18:46:28,000 ERROR JDBCExceptionReporter:72 - No value specified for parameter 1
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
at PersonsManager2.getPersona(PersonsManager2.java:33)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 33 more
exceptions.DatastoreException
at exceptions.DatastoreException.datastoreError(DatastoreException.java:28)
at PersonsManager2.getPersona(PersonsManager2.java:40)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
at PersonsManager2.getPersona(PersonsManager2.java:33)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 33 more
18:46:28,015 WARN RequestProcessor:516 - Unhandled Exception thrown: class exceptions.DatastoreException
18:46:28,015 ERROR [Personas]:253 - Servlet.service() para servlet Personas lanzó excepción
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
at PersonsManager2.getPersona(PersonsManager2.java:33)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)


Debug level Hibernate log excerpt:


----------------------------------------
"SearchPersonsAction3.java"

............
String dni =((SearchPersonForm)form).getDniAccess();

service = new PersonsManager2();

HttpSession session = request.getSession(false);
if(session!=null)
session.invalidate();
session=request.getSession(true);

PersonaBO personaBO;
personaBO = service.getPersona(dni);
session.setAttribute(IConstants.USER_VIEW_KEY,personaBO);

..............


------------------------------------------

- the files "persons.frm" and "db.opt" in web-inf/classes/personas

Bye
Thank you


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

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The root exception says that you haven't bound anything to parameter one, but seeing as you're using Session.get(), the only place the problem can be is with the "id1" variable. What's in it? It should be an int or Integer. The hibernate exception suggests that there is an int in there, with value 1. If that's the case, then the base exception can't have been thrown, so I'm confused. It looks like you've omitted some important code, or you haven't followed the stack trace properly when deciding what code to post. You'll have to do some more debugging: follow the stack trace to find possible causes of the error.

If you find more information that we can use to track down your problem, please post it. Consider using code tags, as they make exceptions and source code much easier to read.


Top
 Profile  
 
 Post subject: exception.SQLGrammarException: could not load an entity
PostPosted: Tue Apr 11, 2006 5:06 pm 
Newbie

Joined: Fri Apr 07, 2006 5:30 pm
Posts: 4
Location: Buenos Aires
hello.

The generated SQL (show_sql=true). It is completed.

Hibernate: select personabo0_.id as id0_0_, personabo0_.nombre as nombre0_0_, personabo0_.apellido as apellido0_0_, personabo0_.edad as edad0_0_, personabo0_.estadoCivil as estadoCi5_0_0_ from persons5 personabo0_ where personabo0_.id=?
18:46:27,984 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 07001
18:46:28,000 ERROR JDBCExceptionReporter:72 - No value specified for parameter 1
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
at PersonsManager2.getPersona(PersonsManager2.java:33)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 33 more
exceptions.DatastoreException
at exceptions.DatastoreException.datastoreError(DatastoreException.java:28)
at PersonsManager2.getPersona(PersonsManager2.java:40)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
at PersonsManager2.getPersona(PersonsManager2.java:33)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
... 33 more
18:46:28,015 WARN RequestProcessor:516 - Unhandled Exception thrown: class exceptions.DatastoreException
18:46:28,015 ERROR [Personas]:253 - Servlet.service() para servlet Personas lanzó excepción
org.hibernate.exception.SQLGrammarException: could not load an entity: [vista.PersonaBO#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:826)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:819)
at PersonsManager2.getPersona(PersonsManager2.java:33)
at SearchPersonAction3.execute(SearchPersonAction3.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)


"SearchPersonsAction3.java"

Code:
public class SearchPersonAction3 extends Action
{
   
   
   
   public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
   throws Exception
   {
      
      ActionForward forward = null;
      IManejadorPersonas service = null;
      
   
      
      try
      {
         
         
         String dni =((SearchPersonForm)form).getDniAccess();
         
      
         
         service = new PersonsManager2();
         
         
         HttpSession session = request.getSession(false);
         
         if(session!=null)
            session.invalidate();
         
         
         session=request.getSession(true);
         
         
         PersonaBO personaBO;
         personaBO = service.getPersona(dni);
            
         
         
         
         session.setAttribute(IConstants.USER_VIEW_KEY,personaBO);
         
         
         
         
         
         forward = mapping.findForward("success");
         
         

         
      }catch(Exception ex)
      {
         ServletContext context = getServlet().getServletContext();
         context.log("Problema de crear el servicio");
         ex.printStackTrace();
         throw DatastoreException.datastoreError(ex);
         
      }   
      
      return forward;
      
   
   
   }
   
}





"PersonsManager2.java"

Code:
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);
      }
      
      if (personaBO==null)
         throw DatastoreException.objectNotFound();
         
         
      return personaBO;
      
      
   }




bye bye and thank you


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 5:42 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
There are two problems:

1) You haven't verified that "((SearchPersonForm)form).getDniAccess()" is returning anything. If it returns null, then "(PersonaBO)session.get(PersonaBO.class,id1);" won't work.

2) "((SearchPersonForm)form).getDniAccess()" returns a String, but your mapping specifies that the id of PersonaBO is an integer. You must convert the String to an Integer.

This code should do the trick:
Code:
String dni =((SearchPersonForm)form).getDniAccess();
if (dni == null)
{
  // Handle error, display error page saying parameter not entered
)

Integer idparam = null;
try
{
  idparam = Integer.decode(dni);
}
catch (NumberFormatException e)
{
  // log error, display error page saying illegal parameter entered.
}
Then you can use idparam as the parameter to Session.get().


Top
 Profile  
 
 Post subject: about entity
PostPosted: Fri Apr 21, 2006 12:54 pm 
Newbie

Joined: Fri Apr 07, 2006 5:30 pm
Posts: 4
Location: Buenos Aires
i thank you. You helped me.
Bye bye


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.