-->
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.  [ 9 posts ] 
Author Message
 Post subject: No row with the given identifier exists
PostPosted: Tue Jan 10, 2006 1:13 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
Hibernate version: 3.0

Hello everyone,

I have the following query:

Code:
                    Query select = session.createQuery("from Produto p, Indice i " +
                            "where p.dataExclusao is null " +
                            " and tipo = 1  or tipo = null " +
                            " and publicar='T' " +
                            " and i.produto.produto = p.produto " +
                            " and i.tipoVenda.tipoVenda = ? " +
                            " order by p.produto");


And I'm receiving the following error:
Code:
java.lang.RuntimeException: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [auge.bean.Produto#9013]


The reason why it happens is obvious: some rows in Indice have no corresponding in Produto. I can't use a "not-found=ignore" because it's part of the ID. Here goes the mapping:

Code:
  <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
         "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping>
    <class name="auge.bean.Indice" table="INDICES" >
        <composite-id>
            <key-many-to-one name="tipoVenda" column="tipoVenda" class="auge.bean.TipoVenda"
                    lazy="false"/>       
            <key-many-to-one name="produto" column="produto" class="auge.bean.Produto"
                    lazy="false"/>       
        </composite-id>         
        <property name="preco" column="preco" type="java.lang.Float" />   
    </class>   
</hibernate-mapping>


The thing is that I don't have and I won't have corresponding rows for each row, and that's just the way I need it. How do I do to get only the rows that have corresponding rows in the other class, avoiding the error?

My second question is: knowing that I am selecting not one, but two sets of objects in a list, how will I (in my Java and JSTL code) access each of them? How do I separate them?

Thank you very much

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 6:37 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
you will receive a tuple of data, i.e. a List of array holding your Objects. This is explained in the Hibernate reference.

I am just wondering if you could use
and i.produto = p
instead of
i.produto.produto = p.produto

Regards
Sebastian

Please rate, if this helped.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:22 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
Thank you very much for the attention.
I tried the suggested change on my query but it had no effects. I still receive the "No row with the given identifier".

Can someone help with this error?

About the List of array holding your Objects, where is the part in Hibernate where it is referenced? 'cause I looked for it and still didn't find it. Any help is appreciated. Thanks.

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:26 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
reference chapter 10.4.1

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:35 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
"10.4.1. Long session with automatic versioning" ?

I'm sorry for being stupid enough not to find it, but is it here that I'm supposed to look? http://www.hibernate.org/hib_docs/reference/en/html/

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:36 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
We are having different reference versions.
Title is
working with objects -> querying -> Executing queries

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:58 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
Thank you very much. I found it right here: http://www.hibernate.org/hib_docs/v3/re ... state.html

Now I just gotta find a way to solve problem number 01. I'm thinking about doing some very ugly and wrong thing to my mapping if I don't find the good looking way to do it. Still accepting help.

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 7:18 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
somethink like may help

select i from Indice i left join i.produto as p
where p <> null and p.dataExclusao is null
i.tipVenda = ?

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 8:05 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
It worked. Thank you.


ps.: I tried to rate you again but the site said the maximum number was reached. Well, thanks then.

_________________
Don't forget to rate if the post helped!


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