-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can't Retrive Data Using JBOSS
PostPosted: Fri Aug 19, 2005 8:49 am 
Newbie

Joined: Tue Aug 09, 2005 1:42 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: hibernate3.0

Mapping documents:
<?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="Tb_User" table="tb_user">

<id name="user_name" unsaved-value="null">
<column name="user_name" sql-type="varchar(20)" not-null="true"/>
<generator class="assigned">
</generator>

</id>

<property name="pwd"><column name="pwd" sql-type="varchar(50)" /></property>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
public boolean dataRetrive(String uname,String passwd){

boolean flag=false;
try{
Tb_User user=new Tb_User(uname,passwd);
Configuration cfg=new Configuration();
//cfg.configure("\\META-INF\\hibernate.cfg.xml");
cfg.configure(new File(System.getProperties().getProperty("sun.boot.library.path")+"\\hibernate.cfg.xml"));
SessionFactory sessionFactory=cfg.buildSessionFactory();
System.out.println("session created");
Session session=sessionFactory.openSession();
Transaction tx=session.beginTransaction();
System.out.println("nvbn");
Query q=session.createQuery("select user.user_name,user.pwd from Tb_User user");
Iterator iter=q.iterate();
System.out.print(iter.hasNext());
while (iter.hasNext()) {
System.out.println("popop");
user = (Tb_User)iter.next();
System.out.println(user.getuser_name());
System.out.println(user.getpwd());
if(uname.equals(user.getuser_name())&&passwd.equals(user.getpwd()))
flag=true;
}
tx.commit();
session.flush();
session.close();
}catch(Exception e){
e.printStackTrace();
}
return flag;
}

}
Full stack trace of any exception that occurs:
There is no Error but iterator.hashnext giving result false.
18:18:38,406 INFO [STDOUT] setSessionContext()
18:18:38,406 INFO [STDOUT] ejbcreate()
18:18:38,406 INFO [Configuration] configuring from file: hibernate.cfg.xml
18:18:38,500 INFO [Configuration] Mapping resource: Tb_User.hbm.xml
18:18:38,515 INFO [HbmBinder] Mapping class: Tb_User -> tb_user
18:18:38,515 INFO [Configuration] Configured SessionFactory: java:/comp/Hello
18:18:38,515 INFO [Configuration] processing extends queue
18:18:38,515 INFO [Configuration] processing collection mappings
18:18:38,515 INFO [Configuration] processing association property references
18:18:38,515 INFO [Configuration] processing foreign key constraints
18:18:38,515 INFO [ConnectionProviderFactory] Initializing connection provider:
org.hibernate.connection.DriverManagerConnectionProvider
18:18:38,515 INFO [DriverManagerConnectionProvider] Using Hibernate built-in co
nnection pool (not for production use!)
18:18:38,515 INFO [DriverManagerConnectionProvider] Hibernate connection pool s
ize: 10
18:18:38,515 INFO [DriverManagerConnectionProvider] autocommit mode: false
18:18:38,515 INFO [DriverManagerConnectionProvider] using driver: com.microsoft
.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://192.168.16.5:
1433
18:18:38,515 INFO [DriverManagerConnectionProvider] connection properties: {use
r=sa, password=sa}
18:18:38,593 INFO [SettingsFactory] RDBMS: Microsoft SQL Server, version: Micro
soft SQL Server 2000 - 8.00.194 (Intel X86)
Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Personal Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

18:18:38,593 INFO [SettingsFactory] JDBC driver: SQLServer, version: 2.2.0040
18:18:38,609 INFO [Dialect] Using dialect: org.hibernate.dialect.SQLServerDiale
ct
18:18:38,609 INFO [TransactionFactoryFactory] Transaction strategy: org.hiberna
te.transaction.JTATransactionFactory
18:18:38,609 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.pr
ovider.url=jnp://localhost:1099, java.naming.factory.initial=org.jnp.interfaces.
NamingContextFactory}
18:18:38,609 INFO [TransactionManagerLookupFactory] instantiating TransactionMa
nagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
18:18:38,609 INFO [TransactionManagerLookupFactory] instantiated TransactionMan
agerLookup
18:18:38,609 INFO [TransactionManagerLookupFactory] instantiating TransactionMa
nagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
18:18:38,609 INFO [TransactionManagerLookupFactory] instantiated TransactionMan
agerLookup
18:18:38,609 INFO [SettingsFactory] Automatic flush during beforeCompletion():
disabled
18:18:38,609 INFO [SettingsFactory] Automatic session close at end of transacti
on: disabled
18:18:38,609 INFO [SettingsFactory] Scrollable result sets: enabled
18:18:38,609 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
18:18:38,609 INFO [SettingsFactory] Connection release mode: null
18:18:38,609 INFO [SettingsFactory] Default batch fetch size: 1
18:18:38,609 INFO [SettingsFactory] Generate SQL with comments: disabled
18:18:38,609 INFO [SettingsFactory] Order SQL updates by primary key: disabled
18:18:38,609 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.AST
QueryTranslatorFactory
18:18:38,609 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
18:18:38,609 INFO [SettingsFactory] Query language substitutions: {}
18:18:38,609 INFO [SettingsFactory] Second-level cache: enabled
18:18:38,609 INFO [SettingsFactory] Query cache: disabled
18:18:38,609 INFO [SettingsFactory] Cache provider: org.hibernate.cache.Hashtab
leCacheProvider
18:18:38,609 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
18:18:38,609 INFO [SettingsFactory] Structured second-level cache entries: disa
bled
18:18:38,609 INFO [SettingsFactory] Echoing all SQL to stdout
18:18:38,609 INFO [SettingsFactory] Statistics: disabled
18:18:38,609 INFO [SettingsFactory] Deleted entity synthetic identifier rollbac
k: disabled
18:18:38,609 INFO [SettingsFactory] Default entity-mode: pojo
18:18:38,640 INFO [SessionFactoryImpl] building session factory
18:18:38,750 INFO [SessionFactoryObjectFactory] Factory name: java:/comp/Hello
18:18:38,750 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.pr
ovider.url=jnp://localhost:1099, java.naming.factory.initial=org.jnp.interfaces.
NamingContextFactory}
18:18:38,750 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: jav
a:/comp/Hello
18:18:38,750 WARN [SessionFactoryObjectFactory] InitialContext did not implemen
t EventContext
18:18:38,750 INFO [Dialect] Using dialect: org.hibernate.dialect.SQLServerDiale
ct
18:18:38,750 INFO [Configuration] processing extends queue
18:18:38,750 INFO [Configuration] processing collection mappings
18:18:38,750 INFO [Configuration] processing association property references
18:18:38,750 INFO [Configuration] processing foreign key constraints
18:18:38,750 INFO [Configuration] processing extends queue
18:18:38,750 INFO [Configuration] processing collection mappings
18:18:38,750 INFO [Configuration] processing association property references
18:18:38,750 INFO [Configuration] processing foreign key constraints
18:18:38,750 INFO [SchemaExport] Running hbm2ddl schema export
18:18:38,750 INFO [SchemaExport] exporting generated schema to database
18:18:38,750 INFO [ConnectionProviderFactory] Initializing connection provider:
org.hibernate.connection.DriverManagerConnectionProvider
18:18:38,750 INFO [DriverManagerConnectionProvider] Using Hibernate built-in co
nnection pool (not for production use!)
18:18:38,750 INFO [DriverManagerConnectionProvider] Hibernate connection pool s
ize: 10
18:18:38,750 INFO [DriverManagerConnectionProvider] autocommit mode: false
18:18:38,750 INFO [DriverManagerConnectionProvider] using driver: com.microsoft
.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://192.168.16.5:
1433
18:18:38,750 INFO [DriverManagerConnectionProvider] connection properties: {use
r=sa, password=sa}
18:18:39,437 INFO [SchemaExport] schema export complete
18:18:39,437 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
18:18:39,437 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Database changed to master
18:18:39,437 WARN [JDBCExceptionReporter] SQL Warning: 5701, SQLState: 01000
18:18:39,437 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed database context to 'master'.
18:18:39,437 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
18:18:39,437 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Language changed to us_english
18:18:39,437 WARN [JDBCExceptionReporter] SQL Warning: 5703, SQLState: 01000
18:18:39,437 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed language setting to us_english.
18:18:39,437 INFO [DriverManagerConnectionProvider] cleaning up connection pool
: jdbc:microsoft:sqlserver://192.168.16.5:1433
18:18:39,437 INFO [Dialect] Using dialect: org.hibernate.dialect.SQLServerDiale
ct
18:18:39,453 INFO [Configuration] processing extends queue
18:18:39,453 INFO [Configuration] processing collection mappings
18:18:39,453 INFO [Configuration] processing association property references
18:18:39,453 INFO [Configuration] processing foreign key constraints
18:18:39,453 INFO [Configuration] processing extends queue
18:18:39,453 INFO [Configuration] processing collection mappings
18:18:39,453 INFO [Configuration] processing association property references
18:18:39,453 INFO [Configuration] processing foreign key constraints
18:18:39,453 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.pr
ovider.url=jnp://localhost:1099, java.naming.factory.initial=org.jnp.interfaces.
NamingContextFactory}
18:18:39,453 INFO [SessionFactoryImpl] Checking 0 named queries
18:18:39,453 INFO [STDOUT] session created
18:18:39,468 INFO [STDOUT] nvbn
18:18:39,468 INFO [STDOUT] Hibernate: select tb_user0_.user_name as col_0_0_, t
b_user0_.pwd as col_1_0_ from tb_user tb_user0_
18:18:39,484 INFO [STDOUT]false
18:18:39,484 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
18:18:39,484 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Database changed to master
18:18:39,500 WARN [JDBCExceptionReporter] SQL Warning: 5701, SQLState: 01000
18:18:39,500 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed database context to 'master'.
18:18:39,500 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
18:18:39,500 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Language changed to us_english
18:18:39,500 WARN [JDBCExceptionReporter] SQL Warning: 5703, SQLState: 01000
18:18:39,500 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed language setting to us_english.
18:19:39,984 INFO [DriverManagerConnectionProvider] cleaning up connection pool
: jdbc:microsoft:sqlserver://192.168.16.5:1433

Name and version of the database you are using:
MS Sql Server
The generated SQL (show_sql=true):
18:18:39,468 INFO [STDOUT] Hibernate: select tb_user0_.user_name as col_0_0_, t
b_user0_.pwd as col_1_0_ from tb_user tb_user0_
Debug level Hibernate log excerpt:

logr4j


Top
 Profile  
 
 Post subject: Re: Can't Retrive Data Using JBOSS
PostPosted: Fri Aug 19, 2005 4:55 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
make sure you have the following line in your hibernate.cfg.xml file.

<mapping resource="Tbl_User.hbm.xml" />

Or Configure Hibernate to use this mapping in one of the many other ways.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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