-->
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: Query not being executed but there are no errors/exceptions
PostPosted: Thu Jun 16, 2005 2:24 pm 
Newbie

Joined: Tue May 10, 2005 2:22 pm
Posts: 10
Hibernate version: 3.0.5

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs: None

Name and version of the database you are using: MS SQLServer 2000

The generated SQL (show_sql=true): Hibernate is not showing it

Debug level Hibernate log excerpt:

2005-06-16 12:06:04,312 INFO hibernate.cfg.Environment Hibernate 3.0.5
2005-06-16 12:06:04,312 INFO hibernate.cfg.Environment hibernate.properties not found
2005-06-16 12:06:04,312 INFO hibernate.cfg.Environment using CGLIB reflection optimizer
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory RDBMS: Microsoft SQL Server, version: 08.00.0534
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.0.3
2005-06-16 12:06:08,906 INFO hibernate.dialect.Dialect Using dialect: org.hibernate.dialect.SQLServerDialect
2005-06-16 12:06:08,906 INFO hibernate.transaction.TransactionFactoryFactory Using default transaction strategy (direct JDBC transactions)
2005-06-16 12:06:08,906 INFO hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory Automatic flush during beforeCompletion(): disabled
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory Automatic session close at end of transaction: disabled
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory Scrollable result sets: enabled
2005-06-16 12:06:08,906 DEBUG hibernate.cfg.SettingsFactory Wrap result sets: disabled
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory JDBC3 getGeneratedKeys(): disabled
2005-06-16 12:06:08,906 INFO hibernate.cfg.SettingsFactory Connection release mode: null
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Maximum outer join fetch depth: 3
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Default batch fetch size: 1
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Generate SQL with comments: disabled
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Order SQL updates by primary key: disabled
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2005-06-16 12:06:08,922 INFO hql.ast.ASTQueryTranslatorFactory Using ASTQueryTranslatorFactory
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Query language substitutions: {}
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Second-level cache: enabled
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Query cache: disabled
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Cache provider: org.hibernate.cache.EhCacheProvider
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Optimize cache for minimal puts: disabled
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Structured second-level cache entries: disabled
2005-06-16 12:06:08,922 DEBUG hibernate.exception.SQLExceptionConverterFactory Using dialect defined converter
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Echoing all SQL to stdout
2005-06-16 12:06:08,922 INFO hibernate.cfg.SettingsFactory Statistics: disabled
2005-06-16 12:06:08,969 INFO hibernate.cfg.SettingsFactory Deleted entity synthetic identifier rollback: disabled
2005-06-16 12:06:08,969 INFO hibernate.cfg.SettingsFactory Default entity-mode: pojo
2005-06-16 12:06:08,969 INFO hibernate.impl.SessionFactoryImpl building session factory
2005-06-16 12:06:08,969 DEBUG hibernate.impl.SessionFactoryImpl Session factory constructed with filter configurations : {}
2005-06-16 12:06:09,781 INFO [HibernateProviderDAO] Searching
2005-06-16 12:06:09,797 DEBUG hibernate.impl.SessionImpl opened session at timestamp: 4583199415488512
2005-06-16 12:06:09,797 DEBUG [HibernateProviderDAO] got session org.hibernate.impl.SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]] ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
2005-06-16 12:06:09,797 DEBUG [HibernateProviderDAO] executing query
2005-06-16 12:06:09,797 DEBUG hibernate.jdbc.JDBCContext after autocommit
2005-06-16 12:06:09,797 DEBUG hibernate.impl.SessionImpl after transaction completion
2005-06-16 12:06:09,797 DEBUG [HibernateProviderDAO] after findProviders()
2005-06-16 12:06:09,797 DEBUG hibernate.impl.SessionImpl closing session
2005-06-16 12:06:09,797 INFO [HibernateProviderDAO] Query time = 0
2005-06-16 12:06:09,797 WARN [HibernateProviderDAO] Cannot find key

The code is running in a web application under WebSphere 5.1.1 on Windows Server 2003. As can be seen by the log output, hibernate.show_sql is true yet Hibernate is not outputting any generated SQL between the openSession() and closeSession(). So, we always get back an empty list from Criteria.list(). There are no exceptions or other errors being generated.


Top
 Profile  
 
 Post subject: transaction or flush
PostPosted: Thu Jun 16, 2005 4:30 pm 
Newbie

Joined: Fri Jan 16, 2004 2:37 am
Posts: 5
Location: Columbus, Ohio
Are you wrapping your code in a transaction? or are you calling flush() on the session. Try one those two methods. Remember session.close does not synchronize the session with the db.


Top
 Profile  
 
 Post subject: Re: transaction or flush
PostPosted: Thu Jun 16, 2005 4:40 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
Could you share the piece of code that you were talking about, That would help to investigate the issue.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 5:22 pm 
Newbie

Joined: Tue May 10, 2005 2:22 pm
Posts: 10
The database I'm accessing is for all purposes, read-only, as the application only executes SQL SELECTS against it. So, transactions are not being used and the app is not issuing a flush on the session. The query is actually very simple and is using the Criteria mechanism to execute against one table. Here is what the app is basically doing after openSession():

Criteria dbCriteria = aSession.createCriteria(RegistryIdentifier.class);
dbCriteria.add(Expression.eq("typeCode", "CPN"));
dbCriteria.add(Expression.eq("regId", aCPN));

logger.debug(HibernateProviderDAO.class, "executing query");
List providerList = dbCriteria.list();

The code has been slightly modified for posting in a public forum.

This query does work fine when run in unit testing outside of WebSphere or when we do not use the WebSphere JDBC provider via JNDI. It just seems to me from looking at the log output that Hibernate is just not sending the query to the JDBC driver. The application also connects to a DB2 database through WebSphere using JNDI and Hiberate works fine there. Hibernate displays the SQL in that case as well.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 3:19 pm 
Newbie

Joined: Tue May 10, 2005 2:22 pm
Posts: 10
I changed the query to use HQL instead of Criteria and now I get an exception:

2005-06-17 12:49:01,562 ERROR hibernate.hql.PARSER *** ERROR: RegistryIdentifier is not mapped.
2005-06-17 12:49:01,578 DEBUG hql.ast.ErrorCounter RegistryIdentifier is not mapped.
RegistryIdentifier is not mapped.
at org.hibernate.hql.ast.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:85)
at org.hibernate.hql.ast.FromElementFactory.addFromElement(FromElementFactory.java:77)
at org.hibernate.hql.ast.FromClause.addFromElement(FromClause.java:67)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:217)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2830)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

The Criteria object is not detecting that the RegistryIdentifier object has not been mapped in the configuration file but HQL does. In effect what was happening is that the hibernate mappings was not actually being read in during initialization. So Criteria doesn't throw an exception if it can't find the specified object in the mapping resources where HQL does. This would seem to be a Criteria bug.


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.