-->
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.  [ 11 posts ] 
Author Message
 Post subject: Unable to retrieve data from DB
PostPosted: Thu Aug 31, 2006 3:09 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,

I am unable to retrieve field values from the mysql db.

My POJO is in package pack.Hris
DB table is candidate, field in the table is firstname.

On executing the following code my result object is empty.

here is a piece of code under pack.HrisManager :
"id" is private Long id in pack.Hris

List result = session.createQuery("select hris.firstname from pack.Hris as hris where hris.id>101").list();

// Check for success or failure
if(result.isEmpty()){
System.out.println("The list is empty");
}
else {
for (int i = 0; i<result.size(); i++) {
System.out.println("In for loop" + i);
Hris hris = (Hris) result.get(i);
System.out.println("Candidate First Name: " + hris.getFirstname());
}

My log messages show:
Session factory Initialized
Hibernate: select hris0_.firstname as col_0_0_ from candidate hris0_ where hris0_.candidateid>101
Session Closed

Hris.hbm file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="pack.Hris" table="candidate">
<id name="id" column="candidateid" type="java.lang.Long">
<generator class="increment"/>
</id>
<property name="firstname" column="firstname" length="30" type="java.lang.String"/>
<property name="lastname" column="lastname" length="30" type="java.lang.String"/>
<property name="state" column="state" length="2" type="java.lang.String"/>

</class>

</hibernate-mapping>

And in hibernate.cfg.xml file i set the following field:
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>


Please let me the solution for this


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 4:31 pm 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
Hi,

You should get a ClassCastException because
"select hris.firstname from pack.Hris as hris where hris.id>101"

will return a list of Object[] and Object will be string, ie firstname

To get a list of Object you should have done:
"select hris from pack.Hris as hris where hris.id>101"
or
"from pack.Hris as hris where hris.id>101"


Take a look at your log file (putting log4j.jar in the classpath)

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 8:30 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,

Thanks for the reply.
I made the changes as told, but the list is still empty.
I have log4j.jar in my classpath.
log messages:
C:\Sample_java\hris_hib>java -classpath .\lib\hibernate3.jar;.\lib\log4j-1.2.9.jar;.\lib\antlr-2.7.4.jar;.\lib\asm.jar;
.\lib\jta.jar;.\lib\commons-logging-1.0.4.jar;.\lib\mysql-connector-java-3.1.13-bin.jar;
.\lib\cglib-2.1.3.jar;.\lib\commons-collections-2.1.1.jar;.\lib\dom4j-1.5.2.jar;.\lib\jdbc2_0-stdext.jar;.\bin pack.HrisManager
INFO - Hibernate 3.1.3
INFO - hibernate.properties not found
INFO - using CGLIB reflection optimizer
INFO - using JDK 1.4 java.sql.Timestamp handling
INFO - configuring from resource: /hibernate.cfg.xml
INFO - Configuration resource: /hibernate.cfg.xml
INFO - Reading mappings from resource: pack/Hris.hbm.xml
INFO - Mapping class: pack.Hris -> candidate
INFO - Configured SessionFactory: null
INFO - Using Hibernate built-in connection pool (not for production use!)
INFO - Hibernate connection pool size: 1
INFO - autocommit mode: false
INFO - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///test
INFO - connection properties: {user=root, password=****}
INFO - RDBMS: MySQL, version: 4.1.15-nt
INFO - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.13 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
INFO - Using dialect: org.hibernate.dialect.MySQLDialect
INFO - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO - Automatic flush during beforeCompletion(): disabled
INFO - Automatic session close at end of transaction: disabled
INFO - JDBC batch size: 15
INFO - JDBC batch updates for versioned data: disabled
INFO - Scrollable result sets: enabled
INFO - JDBC3 getGeneratedKeys(): enabled
INFO - Connection release mode: auto
INFO - Maximum outer join fetch depth: 2
INFO - Default batch fetch size: 1
INFO - Generate SQL with comments: disabled
INFO - Order SQL updates by primary key: disabled
INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO - Using ASTQueryTranslatorFactory
INFO - Query language substitutions: {}
INFO - Second-level cache: enabled
INFO - Query cache: disabled
INFO - Cache provider: org.hibernate.cache.NoCacheProvider
INFO - Optimize cache for minimal puts: disabled
INFO - Structured second-level cache entries: disabled
INFO - Echoing all SQL to stdout
INFO - Statistics: disabled
INFO - Deleted entity synthetic identifier rollback: disabled
INFO - Default entity-mode: pojo
INFO - building session factory
INFO - Not binding factory to JNDI, no JNDI name configured
INFO - Running hbm2ddl schema export
INFO - exporting generated schema to database
INFO - schema export complete
Session factory Initialized
Hibernate: select hris0_.candidateid as candidat1_0_, hris0_.firstname as firstname0_, hris0_.lastname as lastname0_, hris0_.state as state0_ from candidate hris0_ where hris0_.candidateid=101
The list is empty
Session Closed


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 8:30 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,

Thanks for the reply.
I made the changes as told, but the list is still empty.
I have log4j.jar in my classpath.
log messages:
C:\Sample_java\hris_hib>java -classpath .\lib\hibernate3.jar;.\lib\log4j-1.2.9.jar;.\lib\antlr-2.7.4.jar;.\lib\asm.jar;
.\lib\jta.jar;.\lib\commons-logging-1.0.4.jar;.\lib\mysql-connector-java-3.1.13-bin.jar;
.\lib\cglib-2.1.3.jar;.\lib\commons-collections-2.1.1.jar;.\lib\dom4j-1.5.2.jar;.\lib\jdbc2_0-stdext.jar;.\bin pack.HrisManager
INFO - Hibernate 3.1.3
INFO - hibernate.properties not found
INFO - using CGLIB reflection optimizer
INFO - using JDK 1.4 java.sql.Timestamp handling
INFO - configuring from resource: /hibernate.cfg.xml
INFO - Configuration resource: /hibernate.cfg.xml
INFO - Reading mappings from resource: pack/Hris.hbm.xml
INFO - Mapping class: pack.Hris -> candidate
INFO - Configured SessionFactory: null
INFO - Using Hibernate built-in connection pool (not for production use!)
INFO - Hibernate connection pool size: 1
INFO - autocommit mode: false
INFO - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///test
INFO - connection properties: {user=root, password=****}
INFO - RDBMS: MySQL, version: 4.1.15-nt
INFO - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.13 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
INFO - Using dialect: org.hibernate.dialect.MySQLDialect
INFO - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO - Automatic flush during beforeCompletion(): disabled
INFO - Automatic session close at end of transaction: disabled
INFO - JDBC batch size: 15
INFO - JDBC batch updates for versioned data: disabled
INFO - Scrollable result sets: enabled
INFO - JDBC3 getGeneratedKeys(): enabled
INFO - Connection release mode: auto
INFO - Maximum outer join fetch depth: 2
INFO - Default batch fetch size: 1
INFO - Generate SQL with comments: disabled
INFO - Order SQL updates by primary key: disabled
INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO - Using ASTQueryTranslatorFactory
INFO - Query language substitutions: {}
INFO - Second-level cache: enabled
INFO - Query cache: disabled
INFO - Cache provider: org.hibernate.cache.NoCacheProvider
INFO - Optimize cache for minimal puts: disabled
INFO - Structured second-level cache entries: disabled
INFO - Echoing all SQL to stdout
INFO - Statistics: disabled
INFO - Deleted entity synthetic identifier rollback: disabled
INFO - Default entity-mode: pojo
INFO - building session factory
INFO - Not binding factory to JNDI, no JNDI name configured
INFO - Running hbm2ddl schema export
INFO - exporting generated schema to database
INFO - schema export complete
Session factory Initialized
Hibernate: select hris0_.candidateid as candidat1_0_, hris0_.firstname as firstname0_, hris0_.lastname as lastname0_, hris0_.state as state0_ from candidate hris0_ where hris0_.candidateid=101
The list is empty
Session Closed


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 01, 2006 7:49 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
make sure that
Code:
select count(*) from candidate where candidateid=101

returns more than 0

if it returns more than 0
customize log4.xml or log4j.properties

to set the LEVEL of "org.hibernate' and "net.sf.hibernate" loggers to DEBUG

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 10:49 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,

I made the changes you told except the log4j part, coz i never understood about it.
now i get the following error:
Session factory Initialized
Session Initialized
Hibernate: select count(*) as col_0_0_ from candidate hris0_ where hris0_.candidateid=101
The result value is : [0]
In for loop 0
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer
at pack.HrisManager.table(HrisManager.java:42)
at pack.HrisManager.main(HrisManager.java:18)

My code is :
package pack;

import java.io.Serializable;
import java.util.*;
import org.hibernate.*;
import org.hibernate.SessionFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;



public class HrisManager implements Serializable {
public static void main(String args[]) {
HrisManager mgr = new HrisManager();
mgr.table();
}

void table()
{
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

List result = session.createQuery("select count(*) from pack.Hris as hris where hris.id=101").list();
System.out.println("The result value is : " + result);

// Check for success or failure
if(result.isEmpty()){
System.out.println("The list is empty:" + result);
}
else {
for (int i = 0; i<result.size(); i++) {
System.out.println("In for loop" + i);
Hris hris = (Hris) result.get(i);
System.out.println("Candidate First Name: " + hris.getFirstname());
}
tx.commit();
}

HibernateUtil.closeSession();
}
}


I guess the error is at Hris hris = (Hris) result.get(i);
Please let me know i can i overcome this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 1:26 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
doing
"select hris.firstname from pack.Hris as hris where hris.id>101"

you will get a List of Object[] with only one element in each array: the value of first name for the row

doing
"select count(*) from pack.Hris as hris where hris.id>101"

you will get a List of Object[] with only one element in the List
and only one element in this array: the "count" itself.

I proposed you do the "select count(*)" in a SQL editor like
SquirrelSQL http://squirrel-sql.sourceforge.net/ to make sure there is at least one row matching you constraints (ie id > 101)

With log4j.xml, idea was to properly configure log4j adding log4j.xml or log4j.properties in your classpath. You then could increase log level of org.hibernate to DEBUG (increase verbosity of Hibernate)

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 4:09 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,
here is the log message. Can you please help find where the error is as am unable to find it.
I did try " select count(*) " in mysql i got the correct result.

11:54:22,353 DEBUG DTDEntityResolver:22 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
11:54:22,353 DEBUG DTDEntityResolver:24 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
11:54:22,353 DEBUG DTDEntityResolver:34 - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
11:54:22,673 DEBUG Configuration:1269 - hibernate.connection.driver_class=com.mysql.jdbc.Driver
11:54:22,673 DEBUG Configuration:1269 - hibernate.connection.url=jdbc:mysql:///test
11:54:22,683 DEBUG Configuration:1269 - hibernate.connection.username=root
11:54:22,683 DEBUG Configuration:1269 - hibernate.connection.password=pwd
11:54:22,723 DEBUG Configuration:1269 - dialect=org.hibernate.dialect.MySQLDialect
11:54:22,723 DEBUG Configuration:1269 - current_session_context_class=thread
11:54:22,723 DEBUG Configuration:1269 - connection.pool_size=1
11:54:22,723 DEBUG Configuration:1269 - hbm2ddl.auto=create
11:54:22,723 DEBUG Configuration:1269 - cache.provider_class=org.hibernate.cache.NoCacheProvider
11:54:22,743 DEBUG Configuration:1269 - show_sql=true
11:54:22,803 DEBUG Configuration:1269 - hbm2ddl.auto=create
11:54:22,834 DEBUG Configuration:1269 - transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
11:54:22,834 DEBUG Configuration:1464 - null<-org.dom4j.tree.DefaultAttribute@10ef90c [Attribute: name resource value "pack/Hris.hbm.xml"]
11:54:22,834 INFO Configuration:469 - Reading mappings from resource: pack/Hris.hbm.xml
11:54:22,854 DEBUG DTDEntityResolver:22 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
11:54:22,854 DEBUG DTDEntityResolver:24 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
11:54:22,864 DEBUG DTDEntityResolver:34 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
11:54:23,855 INFO HbmBinder:309 - Mapping class: pack.Hris -> candidate
11:54:23,905 DEBUG HbmBinder:1261 - Mapped property: id -> candidateid
11:54:23,995 DEBUG HbmBinder:1261 - Mapped property: firstname -> firstname
11:54:24,005 DEBUG HbmBinder:1261 - Mapped property: lastname -> lastname
11:54:24,005 DEBUG HbmBinder:1261 - Mapped property: state -> state
11:54:24,005 INFO Configuration:1419 - Configured SessionFactory: null

11:54:24,025 DEBUG Configuration:1167 - Preparing to build session factory with filters : {}
11:54:24,035 DEBUG Configuration:1002 - processing extends queue
11:54:24,035 DEBUG Configuration:1006 - processing collection mappings
11:54:24,035 DEBUG Configuration:1017 - processing native query and ResultSetMapping mappings
11:54:24,035 DEBUG Configuration:1025 - processing association property references
11:54:24,035 DEBUG Configuration:1047 - processing foreign key constraints
11:54:24,596 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
11:54:24,596 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
11:54:24,606 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
11:54:24,666 INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///test
11:54:24,666 INFO DriverManagerConnectionProvider:83 - connection properties: {user=root, password=pwd}
11:54:24,666 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
11:54:24,666 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
11:54:26,479 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:mysql:///test, Isolation Level: 4
11:54:26,489 INFO SettingsFactory:77 - RDBMS: MySQL, version: 4.1.15-nt
11:54:26,489 INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.13 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
11:54:26,489 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
11:54:26,609 INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLDialect
11:54:26,649 INFO TransactionFactoryFactory:34 - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
11:54:26,659 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
11:54:26,669 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
11:54:26,669 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
11:54:26,669 INFO SettingsFactory:136 - JDBC batch size: 15
11:54:26,679 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
11:54:26,679 INFO SettingsFactory:144 - Scrollable result sets: enabled
11:54:26,679 DEBUG SettingsFactory:148 - Wrap result sets: disabled
11:54:26,679 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
11:54:26,689 INFO SettingsFactory:160 - Connection release mode: auto
11:54:26,689 INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
11:54:26,689 INFO SettingsFactory:187 - Default batch fetch size: 1
11:54:26,699 INFO SettingsFactory:191 - Generate SQL with comments: disabled
11:54:26,699 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
11:54:26,699 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
11:54:26,709 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
11:54:26,719 INFO SettingsFactory:203 - Query language substitutions: {}
11:54:26,729 INFO SettingsFactory:209 - Second-level cache: enabled
11:54:26,739 INFO SettingsFactory:213 - Query cache: disabled
11:54:26,749 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
11:54:26,759 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
11:54:26,769 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
11:54:26,779 DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter
11:54:26,799 INFO SettingsFactory:257 - Echoing all SQL to stdout
11:54:26,799 INFO SettingsFactory:264 - Statistics: disabled
11:54:26,799 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
11:54:26,799 INFO SettingsFactory:283 - Default entity-mode: pojo
11:54:27,020 INFO SessionFactoryImpl:154 - building session factory
11:54:27,030 DEBUG SessionFactoryImpl:165 - Session factory
11:54:28,872 DEBUG AbstractEntityPersister:2447 - Static SQL for entity: pack.Hris
11:54:28,882 DEBUG AbstractEntityPersister:2449 - Version select: select candidateid from candidate where candidateid =?
11:54:28,882 DEBUG AbstractEntityPersister:2450 - Snapshot select: select hris_.candidateid, hris_.firstname as firstname0_, hris_.lastname as lastname0_, hris_.state as state0_ from candidate hris_ where hris_.candidateid=?
11:54:28,882 DEBUG AbstractEntityPersister:2452 - Insert 0: insert into candidate (firstname, lastname, state, candidateid) values (?, ?, ?, ?)
11:54:28,882 DEBUG AbstractEntityPersister:2453 - Update 0: update candidate set firstname=?, lastname=?, state=? where candidateid=?
11:54:28,882 DEBUG AbstractEntityPersister:2454 - Delete 0: delete from candidate where candidateid=?
11:54:28,882 DEBUG AbstractEntityPersister:2457 - Identity insert: insert into candidate (firstname, lastname, state) values (?, ?, ?)
11:54:29,052 DEBUG EntityLoader:79 - Static select for entity pack.Hris: select hris0_.candidateid as candidat1_0_0_, hris0_.firstname as firstname0_0_, hris0_.lastname as lastname0_0_, hris0_.state as state0_0_ from candidate hris0_ where hris0_.candidateid=?
11:54:29,052 DEBUG EntityLoader:79 - Static select for entity pack.Hris: select hris0_.candidateid as candidat1_0_0_, hris0_.firstname as firstname0_0_, hris0_.lastname as lastname0_0_, hris0_.state as state0_0_ from candidate hris0_ where hris0_.candidateid=?
11:54:29,052 DEBUG EntityLoader:79 - Static select for entity pack.Hris: select hris0_.candidateid as candidat1_0_0_, hris0_.firstname as firstname0_0_, hris0_.lastname as lastname0_0_, hris0_.state as state0_0_ from candidate hris0_ where hris0_.candidateid=? for update
11:54:29,062 DEBUG EntityLoader:79 - Static select for entity pack.Hris: select hris0_.candidateid as candidat1_0_0_, hris0_.firstname as firstname0_0_, hris0_.lastname as lastname0_0_, hris0_.state as state0_0_ from candidate hris0_ where hris0_.candidateid=? for update
11:54:29,123 DEBUG EntityLoader:34 - Static select for action ACTION_MERGE on entity pack.Hris: select hris0_.candidateid as candidat1_0_0_, hris0_.firstname as firstname0_0_, hris0_.lastname as lastname0_0_, hris0_.state as state0_0_ from candidate hris0_ where hris0_.candidateid=?
11:54:29,123 DEBUG EntityLoader:34 - Static select for action ACTION_REFRESH on entity pack.Hris: select hris0_.candidateid as candidat1_0_0_, hris0_.firstname as firstname0_0_, hris0_.lastname as lastname0_0_, hris0_.state as state0_0_ from candidate hris0_ where hris0_.candidateid=?
11:54:29,193 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
11:54:29,213 DEBUG SessionFactoryObjectFactory:76 - registered: 40288fe40d8ec7e2010d8ec7eb030000 (unnamed)
11:54:29,223 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
11:54:29,223 DEBUG SessionFactoryImpl:293 - instantiated session factory
11:54:29,253 DEBUG Configuration:1002 - processing extends queue
11:54:29,253 DEBUG Configuration:1006 - processing collection mappings
11:54:29,253 DEBUG Configuration:1017 - processing native query and ResultSetMapping mappings
11:54:29,253 DEBUG Configuration:1025 - processing association property references
11:54:29,253 DEBUG Configuration:1047 - processing foreign key constraints
11:54:29,253 DEBUG Configuration:1002 - processing extends queue
11:54:29,263 DEBUG Configuration:1006 - processing collection mappings
11:54:29,263 DEBUG Configuration:1017 - processing native query and ResultSetMapping mappings
11:54:29,263 DEBUG Configuration:1025 - processing association property references
11:54:29,263 DEBUG Configuration:1047 - processing foreign key constraints
11:54:29,263 INFO SchemaExport:152 - Running hbm2ddl schema export
11:54:29,273 DEBUG SchemaExport:168 - import file not found: /import.sql
11:54:29,273 INFO SchemaExport:177 - exporting generated schema to database
11:54:29,273 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
11:54:29,273 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
11:54:29,283 DEBUG SchemaExport:301 - drop table if exists candidate
11:54:29,373 DEBUG SchemaExport:301 - create table candidate (candidateid bigint not null auto_increment, firstname varchar(30), lastname varchar(30), state varchar(2), primary key (candidateid))
11:54:29,463 INFO SchemaExport:194 - schema export complete
11:54:29,463 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
11:54:29,493 DEBUG SessionFactoryImpl:354 - Checking 0 named HQL queries
11:54:29,493 DEBUG SessionFactoryImpl:374 - Checking 0 named SQL queries
Session factory Initialized
11:54:29,743 DEBUG SessionImpl:219 - opened session at timestamp: 11577416694
Session Initialized
11:54:29,763 DEBUG JDBCTransaction:54 - begin
11:54:29,763 DEBUG ConnectionManager:415 - opening JDBC connection
11:54:29,763 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
11:54:29,763 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
11:54:29,763 DEBUG JDBCTransaction:59 - current autocommit status: false
11:54:29,763 DEBUG JDBCContext:194 - after transaction begin
11:54:29,804 DEBUG QueryPlanCache:69 - unable to locate HQL query plan in cache; generating (select hris from pack.Hris as hris where hris.id>100)
11:54:30,234 DEBUG QueryTranslatorImpl:236 - parse() - HQL: select hris from pack.Hris as hris where hris.id>100
11:54:30,334 DEBUG AST:252 - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[IDENT] 'pack'
| | | \-[IDENT] 'Hris'
| | \-[ALIAS] 'hris'
| \-[SELECT] 'select'
| \-[IDENT] 'hris'
\-[WHERE] 'where'
\-[GT] '>'
+-[DOT] '.'
| +-[IDENT] 'hris'
| \-[IDENT] 'id'
\-[NUM_INT] '100'

11:54:30,334 DEBUG ErrorCounter:68 - throwQueryException() : no errors
11:54:30,645 DEBUG HqlSqlBaseWalker:111 - select << begin [level=1, statement=select]
11:54:30,775 DEBUG FromElement:104 - FromClause{level=1} : pack.Hris (hris) -> hris0_
11:54:30,795 DEBUG FromReferenceNode:51 - Resolved : hris -> hris0_.candidateid
11:54:30,815 DEBUG FromReferenceNode:51 - Resolved : hris -> hris0_.candidateid
11:54:30,835 DEBUG DotNode:541 - getDataType() : id -> org.hibernate.type.LongType@1f6226
11:54:30,845 DEBUG FromReferenceNode:51 - Resolved : hris.id -> hris0_.candidateid
11:54:30,855 DEBUG HqlSqlBaseWalker:117 - select : finishing up [level=1, statement=select]
11:54:30,855 DEBUG HqlSqlWalker:511 - processQuery() : ( SELECT ( {select clause} hris0_.candidateid ) ( FromClause{level=1} candidate hris0_ ) ( where ( > ( hris0_.candidateid hris0_.candidateid id ) 100 ) ) )
11:54:30,905 DEBUG JoinProcessor:128 - Using FROM fragment [candidate hris0_]
11:54:30,905 DEBUG HqlSqlBaseWalker:123 - select >> end [level=1, statement=select]
11:54:30,945 DEBUG AST:222 - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (candidate)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[ALIAS_REF] IdentNode: 'hris0_.candidateid as candidat1_0_' {alias=hris, className=pack.Hris, tableAlias=hris0_}
| \-[SQL_TOKEN] SqlFragment: 'hris0_.firstname as firstname0_, hris0_.lastname as lastname0_, hris0_.state as state0_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[hris], fromElementByTableAlias=[hris0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'candidate hris0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=hris,role=null,tableName=candidate,tableAlias=hris0_,origin=null,colums={,className=pack.Hris}}
\-[WHERE] SqlNode: 'where'
\-[GT] BinaryLogicOperatorNode: '>'
+-[DOT] DotNode: 'hris0_.candidateid' {propertyName=id,dereferenceType=4,propertyPath=id,path=hris.id,tableAlias=hris0_,className=pack.Hris,classAlias=hris}
| +-[ALIAS_REF] IdentNode: 'hris0_.candidateid' {alias=hris, className=pack.Hris, tableAlias=hris0_}
| \-[IDENT] IdentNode: 'id' {originalText=id}
\-[NUM_INT] LiteralNode: '100'

11:54:30,955 DEBUG ErrorCounter:68 - throwQueryException() : no errors
11:54:31,035 DEBUG QueryTranslatorImpl:206 - HQL: select hris from pack.Hris as hris where hris.id>100
11:54:31,045 DEBUG QueryTranslatorImpl:207 - SQL: select hris0_.candidateid as candidat1_0_, hris0_.firstname as firstname0_, hris0_.lastname as lastname0_, hris0_.state as state0_ from candidate hris0_ where hris0_.candidateid>100
11:54:31,045 DEBUG ErrorCounter:68 - throwQueryException() : no errors
11:54:31,085 DEBUG HQLQueryPlan:219 - HQL param location recognition took 10 mills (select hris from pack.Hris as hris where hris.id>100)
11:54:31,176 DEBUG QueryPlanCache:75 - located HQL query plan in cache (select hris from pack.Hris as hris where hris.id>100)
11:54:31,186 DEBUG HQLQueryPlan:148 - find: select hris from pack.Hris as hris where hris.id>100
11:54:31,196 DEBUG QueryParameters:262 - named parameters: {}
11:54:31,206 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:54:31,206 DEBUG SQL:346 - select hris0_.candidateid as candidat1_0_, hris0_.firstname as firstname0_, hris0_.lastname as lastname0_, hris0_.state as state0_ from candidate hris0_ where hris0_.candidateid>100
Hibernate: select hris0_.candidateid as candidat1_0_, hris0_.firstname as firstname0_, hris0_.lastname as lastname0_, hris0_.state as state0_ from candidate hris0_ where hris0_.candidateid>100
11:54:31,206 DEBUG AbstractBatcher:424 - preparing statement
11:54:31,326 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
11:54:31,326 DEBUG Loader:682 - processing result set
11:54:31,336 DEBUG Loader:709 - done processing result set (0 rows)
11:54:31,336 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
11:54:31,336 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:54:31,336 DEBUG AbstractBatcher:470 - closing statement
11:54:31,346 DEBUG Loader:839 - total objects hydrated: 0
11:54:31,356 DEBUG StatefulPersistenceContext:748 - initializing non-lazy collections
The result value is : []
The list is empty:[]
11:54:31,366 DEBUG SessionImpl:268 - closing session
11:54:31,366 DEBUG ConnectionManager:374 - performing cleanup
11:54:31,366 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
11:54:31,366 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
Session Closed

Please help me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 5:14 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
The problem is
11:54:29,283 DEBUG SchemaExport:301 - drop table if exists candidate
11:54:29,373 DEBUG SchemaExport:301 - create table candidate (candidateid bigint not null auto_increment, firstname varchar(30), lastname varchar(30),

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 18, 2006 3:11 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,

Thankyou for ur reply. But i dont understand why is it doing this?
I have no such "drop table" statements in my program.
How can I avoid this?

Is there any problem in the following statement?
"DEBUG QueryPlanCache:69 - unable to locate HQL query plan in cache; generating (select hris from pack.Hris as hris where hris.id>100) "

My hibernate.cfg.xml is:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-configuration (View Source for full doctype...)>
- <hibernate-configuration>
- <session-factory>
- <!-- Database connection settings
-->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:///test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">manoj</property>
- <!-- SQL dialect
-->
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
- <!-- <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
-->
- <!-- Enable Hibernate's automatic session context management
-->
<property name="current_session_context_class">thread</property>
- <!-- JDBC connection pool (use the built-in)
-->
<property name="connection.pool_size">1</property>
- <!--
Drop and re-create the database schema on startup
<property name="hbm2ddl.auto">create</property>

-->
- <!-- Disable the second-level cache
-->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
- <!-- Echo all executed SQL to stdout
-->
<property name="show_sql">true</property>

<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<mapping resource="pack/Hris.hbm.xml" />
</session-factory>
</hibernate-configuration>


Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 2:22 am 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
I got the problem solved.
i had given incorrect DB name in hibernate.cfg.xml.The correct statement is:
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/theclass_TheClassDB?autoReconnect=true</property>
and NOT

<property name="hibernate.connection.url">jdbc:mysql:///test</property>

Neways,thanks for your replies.


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