-->
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.  [ 7 posts ] 
Author Message
 Post subject: Problem with Select query in Hibernate
PostPosted: Thu Feb 16, 2006 5:51 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
Hi All,

I made the mapping correct and the query run fine no errors neither and exceptions.

Once i use the sql query that hibernate did generate, it returns rows.

The code i use is normal query, using a session to create a query and then
just query.list(), but always nada.



here is a part from the log :

17406 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
17406 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: select x.reqId, x.requestType, x.msisdn, x.HLRStatus from com.atos.activdb.model.RequestHistory as x where x.HLRStatus = 7
17406 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select requesthis0_.Request_Id as col_0_0_, requesthis0_.Request_Type as col_1_0_, requesthis0_.Msisdn as col_2_0_, requesthis0_.HLR_Status as col_3_0_ from SEMA_ACTIVPLUS_REQUEST requesthis0_ where requesthis0_.HLR_Status=7
17406 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
17406 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17406 [main] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
17406 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
17406 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
17406 [main] DEBUG org.hibernate.SQL - select requesthis0_.Request_Id as col_0_0_, requesthis0_.Request_Type as col_1_0_, requesthis0_.Msisdn as col_2_0_, requesthis0_.HLR_Status as col_3_0_ from SEMA_ACTIVPLUS_REQUEST requesthis0_ where requesthis0_.HLR_Status=7
17406 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
17469 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
17469 [main] DEBUG org.hibernate.loader.Loader - processing result set
17469 [main] DEBUG org.hibernate.loader.Loader - done processing result set (0 rows)
17469 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
17469 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17469 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
17484 [main] DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections
17484 [main] DEBUG org.hibernate.jdbc.JDBCContext - after autocommit


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 6:04 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
What do you mean by "nada"... please provide more info


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 6:07 am 
Newbie

Joined: Wed Nov 02, 2005 6:07 am
Posts: 12
MikePloed wrote:
What do you mean by "nada"... please provide more info


nada means "Niente, Nothing" or in German: "Nichts, Nix" ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 6:10 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
The mapping is correct, everything seems fine.
but no rows returned.

This is the request i use :

public static String getrecycle = "select x.reqId, x.requestType, x.msisdn,
x.HLRStatus from RequestHistory as x where x.HLRStatus = 7";

public List execute() throws BusinessException,
Throwable {
List requestList;
Session session = HibernateUtil.currentSession();
Query query = session.createQuery(getrecycle);

requestList = query.list();

HibernateUtil.closeSession();
return requestList;

...

}

But once i use the sql query built by hibernate in log, the weird thing is that it returns rows.

So I am quite lost.

Any help will be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 6:18 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Try a bind variable for the where clause.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 6:26 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
Dear Mike,

Even with introducing a bind variable :status

query.setParamter("status", 7);

the query still does not return the supposed rows.


Top
 Profile  
 
 Post subject: IS NULL VALUE IN ROW AFFECT A QUERY
PostPosted: Thu Feb 16, 2006 6:35 am 
Newbie

Joined: Tue Feb 14, 2006 2:58 pm
Posts: 7
Hi All,

Could this be happening ?

In the table I am mapping there some columns in each row can accept null values.

In case I execute a select query on this table, does the null value impact the selection result ???

I mean, if a row contains a null value would it be select or no ???

Thanks in advance for your reply.


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