-->
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.  [ 3 posts ] 
Author Message
 Post subject: UnresolvableObjectException: No row with the given iden...
PostPosted: Thu May 13, 2004 10:36 am 
Newbie

Joined: Thu Apr 08, 2004 7:32 am
Posts: 10
Hello,

I know this topic was discussed several times in this forum. But no thread could help me with MY problem.

First some infos:

hibernate version: 2.1
database: mysql 4.0.12

That's my exception:

Code:
javax.servlet.ServletException: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: pmtool.entities.Kunde
   at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:526)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:467)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1349)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:489)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
   at java.lang.Thread.run(Thread.java:536)


root cause

java.lang.RuntimeException: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: pmtool.entities.Kunde
   at pmtool.factories.KundeData.getKundeList(KundeData.java:204)
   at pmtool.actions.ShowKundenAction.execute(ShowKundenAction.java:30)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1349)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:489)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
   at java.lang.Thread.run(Thread.java:536)
Caused by: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: pmtool.entities.Kunde
   at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
   at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1918)
   at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
   at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
   at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2169)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)
   at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80)
   at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
   at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)
   at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:340)
   at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3089)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
   at net.sf.hibernate.loader.Loader.list(Loader.java:941)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
   at pmtool.factories.KundeData.getKundeList(KundeData.java:198)
   ... 36 more


I've the classes "Kunde", "Job" and "Projekt".

That are the mapping documents:

Kunde.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="pmtool.entities.Kunde" table="kunde">
      <id name="id" type="integer" unsaved-value="null">
         <column name="kunde_id" not-null="true"/>
         <generator class="identity"/>
      </id>
      <property name="name">
         <column name="name" sql-type="varchar(32)" not-null="true"/>
      </property>
      <bag name="jobs" cascade="all" inverse="true" lazy="false" order-by="eingabedatum">
         <key column="kunde_id"/>
         <one-to-many class="pmtool.entities.Job"/>
      </bag>
      <bag name="projekte" cascade="all" inverse="true" lazy="false" order-by="name">
         <key column="kunde_id"/>
         <one-to-many class="pmtool.entities.Projekt"/>
      </bag>
   </class>
</hibernate-mapping>


Projekt.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="pmtool.entities.Projekt" table="projekt">
      <id name="id" type="integer">
         <column name="projekt_id" not-null="true"/>
         <generator class="identity"/>
      </id>
      <property name="name">
         <column name="name" sql-type="varchar(32)" not-null="true"/>
      </property>
      <bag name="jobs" cascade="all" inverse="true" lazy="false" order-by="eingabedatum">
         <key column="projekt_id"/>
         <one-to-many class="pmtool.entities.Job"/>
      </bag>
      <many-to-one name="kunde" column="kunde_id" not-null="true"/>
   </class>
</hibernate-mapping>


Job.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="pmtool.entities.Job" table="job">
      <id name="jobid" type="integer" unsaved-value="null">
         <column name="job_id" not-null="true"/>
         <generator class="identity"/>
      </id>
      <property name="jobname">
         <column name="jobname" sql-type="varchar(32)" not-null="true"/>
      </property>
      <property name="jobart">
         <column name="jobart" not-null="false"/>
      </property>
      <property name="status">
         <column name="status" not-null="false"/>
      </property>
      <property name="deadlineTag">
         <column name="deadlineTag" sql-type="varchar(10)" not-null="false"/>
      </property>
      <property name="deadlineStunde">
         <column name="deadlineStunde" sql-type="varchar(5)" not-null="false"/>
      </property>
      <property name="eingabedatum">
         <column name="eingabedatum" sql-type="varchar(10)" not-null="false"/>
      </property>
      <property name="von">
         <column name="von" sql-type="varchar(5)" not-null="false"/>
      </property>
      <property name="bis">
         <column name="bis" sql-type="varchar(5)" not-null="false"/>
      </property>
      <property name="arbeiten">
         <column name="arbeiten" not-null="false"/>
      </property>
      <property name="auftragsdatum">
         <column name="auftragsdatum" sql-type="varchar(32)" not-null="false"/>
      </property>
      <property name="ansprechpartner">
         <column name="ansprechpartner" not-null="false"/>
      </property>
      <property name="istzeit">
         <column name="istzeit" not-null="false"/>
      </property>
      <property name="richtwert">
         <column name="richtwert" not-null="false"/>
      </property>
      <property name="datum">
         <column name="datum" sql-type="varchar(10)" not-null="false"/>
      </property>
      <property name="beschreibung">
         <column name="beschreibung" not-null="false"/>
      </property>
      <property name="auftragsart">
         <column name="auftragsart" not-null="false"/>
      </property>
      <many-to-one name="kunde" column="kunde_id" not-null="true"/>
      <many-to-one name="projekt" column="projekt_id" not-null="false"/>
   </class>
</hibernate-mapping>


The associations are:
Kunde 1---n Projekt
Projekt 0---n Job
Kunde 1---n Job

A Job can belong to a Projekt or not, but must belong to a Kunde.

When I want to show a list of Kunden, I get the above errors/exceptions.

Here's my java-code (I'm working with struts):

ConnectionFactory.java:
Code:
/**
* Singleton class that creates and returns an open Hibernate <code>Session</code> to the user.
*
* Copyright 2003 Edward Hand
*
* @author Edward Hand
*
*/
public class ConnectionFactory {

   private static ConnectionFactory instance = null;
   private SessionFactory sessionFactory = null;

   private ConnectionFactory()
   {
      try {
         Configuration cfg = new Configuration().
                           addClass(Benutzer.class).
                           addClass(Jobart.class).
                           addClass(Job.class).
                           addClass(Kunde.class).
                           addClass(Projekt.class);
         sessionFactory = cfg.buildSessionFactory();

      }
      catch (MappingException e) {
         System.err.println("Mapping Exception" + e.getMessage());
         throw new RuntimeException(e);
      }
      catch (HibernateException e) {
         System.err.println("Hibernate Exception" + e.getMessage());
         throw new RuntimeException(e);
      }
   }

   public static synchronized ConnectionFactory getInstance() {
      if (instance == null) {
         instance = new ConnectionFactory();
      }
      return instance;
   }

   public Session getSession() {
      try {
         Session s = sessionFactory.openSession();
         return s;
      }
      catch (HibernateException e) {
         System.err.println("Hibernate Exception" + e.getMessage());
         throw new RuntimeException(e);
      }
   }

}


KundeData.java: (parts)
Code:
public class KundeData {
   
   private static KundeData instance = null;

   private KundeData(){
   }

   public static synchronized KundeData getInstance() {
      if (instance == null) {
         instance = new KundeData();
      }
      return instance;
   }

   public List getKundeList() {
      Session session = ConnectionFactory.getInstance().getSession();
      try {
         System.out.println("huhu");
         Query query = session.createQuery(
               "select kunde from pmtool.entities.Kunde kunde order by kunde.name"
               );
         return query.list();
      }
      catch (HibernateException e) {
         System.err.println("Hibernate Exception" + e.getMessage());
         throw new RuntimeException(e);
      }
      finally {
         if (session != null) {
            try {
               session.close();
            }
            catch (HibernateException e) {
               System.err.println("Hibernate Exception" + e.getMessage());
               throw new RuntimeException(e);
            }
         }
      }
   }
   
}


ShowKundenAction.java:
Code:
public class ShowKundenAction extends Action {
   
   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,          HttpServletResponse response) throws HibernateException {
      ActionForward baseForward  = null;
      ActionForward forward  = null;
      baseForward = null;
      if (baseForward != null){
        forward = baseForward;
      } else {
         List kunden = KundeData.getInstance().getKundeList();
         request.setAttribute("kunden", kunden);
         forward = mapping.findForward("goKunden");
         }
      return forward;
   }

}


showkunden.jsp: (parts)
[code]
<logic:iterate id="element" name="kunden" scope="request" type="pmtool.entities.Kunde" >
<tr onMouseover="bgColor='#FFFED1'" onMouseout="bgColor='#FFFFFF'"> <!--bgcolor="#FFFED1"-->
<td><img src="img/trans.gif" width="5" height="15" border="0"></td>
<td class="default"><img src="img/kunde.gif">&nbsp;&nbsp;<bean:write name="element" property="name" />
</td>
<td><img src="img/neu.gif" alt="Neu"><img src="img/bearbeiten.gif" alt="Bearbeiten">&nbsp;&nbsp;<img src="img/loeschen.gif" alt="L


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 3:34 am 
Newbie

Joined: Thu Apr 08, 2004 7:32 am
Posts: 10
Can please someone help me! Thank you!

paula


Top
 Profile  
 
 Post subject: Mistake found!
PostPosted: Fri May 14, 2004 7:56 am 
Newbie

Joined: Thu Apr 08, 2004 7:32 am
Posts: 10
Yeah! I'm so glad, I've found my mistake.
In table "job" there was one job with kunden_id 0.
I'm sorry! But thanks to all, who read my posting.

paula


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