-->
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.  [ 4 posts ] 
Author Message
 Post subject: No results from HQL, generated SQL returns correct value
PostPosted: Wed Dec 08, 2004 7:47 am 
Newbie

Joined: Wed Dec 08, 2004 7:20 am
Posts: 3
Hello,

I am using Oracle 10g and I have strange error that I cannot resolve.

Below are tables with most data columns snipped (otherwise they would be to long)

When I do
Code:
String query = "from BBB si WHERE si.sifra=?";
   Query q = s.createQuery(query);
   q.setParameter(0, sifra10crk);
   Object o = q.uniqueResult();
   SifrantIzpostava si = (SifrantIzpostava) o;


I get null. But if I remove the line below from AAA definition, it works:
,foreign key (IZPOSTAVA_ID) references BBB(id) on delete cascade


Generated SQL returns one row, which is correct. Hibernate log says that 0 rows were returned.

Any ideas?

PS. I changed some names for improved readability, and the code works if foreign key constraint in database is removed, so any typo in there is not the cause.

Thanks.


------ DATABASE ---------



Code:
CREATE TABLE AAA(
ID   NUMBER(4) NOT NULL
,IZPOSTAVA_ID   NUMBER(4) NOT NULL
,constraint PKAAA primary key (id)
,foreign key (IZPOSTAVA_ID) references BBB(id)  on delete cascade
)
/
CREATE TABLE BBB(
ID     NUMBER(4) NOT NULL
,SIFRA   VARCHAR2(10) NOT NULL   
,constraint PKSifrantIzpostava primary key (ID)
,constraint BKSifrantIzpostava unique (SIFRA)
)
/


-------- LOG ----------
    :18:22,042 DEBUG BatcherImpl:249 - preparing statement

    4536 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement

    12:18:22,293 DEBUG Loader:277 - processing result set

    4787 [main] DEBUG net.sf.hibernate.loader.Loader - processing result set

    12:18:22,293 DEBUG Loader:294 - done processing result set (0 rows)

    4787 [main] DEBUG net.sf.hibernate.loader.Loader - done processing result set (0 rows)

    12:18:22,293 DEBUG BatcherImpl:207 - done closing: 0 open PreparedStatements, 0 open ResultSets

    4787 [main] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets

    12:18:22,293 DEBUG BatcherImpl:269 - closing statement


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 7:49 am 
Newbie

Joined: Wed Dec 08, 2004 7:20 am
Posts: 3
I forgot to mention: I am using Hibernate 2.1.6


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 9:24 am 
Newbie

Joined: Wed Dec 08, 2004 7:20 am
Posts: 3
After experimentig for a while I noticed that foreign key plays no role in the problem. If I drop table AAA or BBB a couple of times, it starts working.

Oracle is otherwise stable and consistent when running other programs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 10:10 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
try remove line :
Object o = q.uniqueResult();

regards


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