Urgent! - session.HibernateContext.getSession not working...
beyarecords Oct 26, 2004 8:18 AMHi,
I am having a serious problem getting data to returned to me from postgreSQL 7.4.1 via jndi(JBoss 3.2.6) using session.HibernateContext.getSession(). It seems that a session is being returned but nothing is happening after that. Can anybody tell me wht I am not doing correctly here? Is my java code specified incorrectly? I have specified my
hibernate-service.xml doc as:
jboss.jca:service=LocalTxCM,name=PostgreSQL
java:/hibernate/SessionFactory
java:/PostgreSQL
net.sf.hibernate.dialect.PostgreSQLDialect
net.sf.ehcache.hibernate.Provider
postgres-ds.xml:
<local-tx-datasource>
<jndi-name>PostgreSQL</jndi-name>
<connection-url>jdbc:postgresql://localhost:5432/beyarecords</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>x</user-name>
y
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
</local-tx-datasource>
standardjbosscmp-jdbc.xml:
java:/PostgreSQL
<datasource-mapping>postgreSQL</datasource-mapping>
<type-mapping>
postgreSQL
.................................................................
</type-mapping>
java code:
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.Query;
import org.jboss.hibernate.session.HibernateContext;
try {
HibernateContext session = org.jboss.hibernate.session.HibernateContext.getSession("java:/hibernate/SessionFactory");
//transaction = session.beginTransaction();
//Get User details
Query query = session.createQuery("from test.User as user where user.UserName=:username and user.UserPassword=:password")
.setString("username",username)
.setString("password",password);
user = (User) query.uniqueResult();
//transaction.commit();
//session.close();
} catch (HibernateException e) {
throw new RuntimeException("Exception in Hibernate:: " + e.getMessage(), e);
}
server.log output:
2004-10-26 13:10:24,445 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
2004-10-26 13:10:24,446 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=d1e22501ffd5242300ffd52426a80000
2004-10-26 13:10:24,569 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2004-10-26 13:10:24,784 INFO [org.apache.jk.server.JkCoyoteHandler] Response already commited
many thanks
Uzo