-->
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.  [ 3 posts ] 
Author Message
 Post subject: Conn with datasource in JBOSS app server in hibernate
PostPosted: Wed Oct 15, 2008 7:12 am 
Newbie

Joined: Fri Sep 26, 2008 12:56 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:Hibernate 3.0

Mapping documents:

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

public List findByProperty(String propertyName, Object value) throws DAOException{
//log.debug("finding Users instance with property: " + propertyName + ", value: " + value);
System.out.println("the value of property in the userDAO::"+propertyName+ " Value::"+value);
try {
String queryString = "from Users as model where model."+ propertyName + "= ?";
Query queryObject = this.hibSession.createQuery(queryString);
//Query queryObject = getSession().createQuery(queryString);
System.out.println("the query string::::"+queryString);
System.out.println("the query object::"+queryObject);
queryObject.setParameter(0, value);


System.out.println("after setting the parameter:");
//queryObject.setCacheable(true);

return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}

--------------------------------------------------------------
public HibernateSessionWrapper() throws DAOException {
this.session = (Session) threadLocal.get();

try {
if (this.session == null) {
System.out.println("--------Creating Session--------");
this.session = getSessionFactory().openSession();
System.out.println("after creating session in HibernateSessionWarapper : "+this.session);
if (this.session.connection().getAutoCommit()) {
this.session.connection().setAutoCommit(false);
}
threadLocal.set(this.session);
System.out.println("Getting the session from the thread ::");
}
} catch (HibernateException he) {
he.printStackTrace();
throw new DAOException(he);
} catch (SQLException e) {
e.printStackTrace();
throw new DAOException(e);
} catch (Exception e) {
e.printStackTrace();
throw new DAOException(e);
}

}
-----------------------------------------------------------------

public Query createQuery(String queryString) throws DAOException {
Query result = null;
try {
System.out.println("session value::"+isOpen());
if (isOpen()) {
result = this.session.createQuery(queryString);
System.out.println("result in session "+result);
}
} catch (HibernateException e) {
throw new DAOException(e);
}
return result;
}
---------------------------------------------------------



Full stack trace of any exception that occurs:
### direct messages to file hibernate.log ###
2008-10-15 10:13:44,181 INFO [STDOUT] 10:13:44,181 WARN JDBCExceptionReporter:71 - SQL Error: 17008, SQLState: null
### direct messages to file hibernate.log ###
2008-10-15 10:13:44,181 INFO [STDOUT] 10:13:44,181 ERROR JDBCExceptionReporter:72 - Closed Connection
### direct messages to file hibernate.log ###
2008-10-15 10:13:44,197 INFO [STDOUT] 10:13:44,181 WARN JDBCExceptionReporter:71 - SQL Error: 17008, SQLState: null
### direct messages to file hibernate.log ###
2008-10-15 10:13:44,197 INFO [STDOUT] 10:13:44,197 ERROR JDBCExceptionReporter:72 - Closed Connection
### direct messages to file hibernate.log ###
2008-10-15 10:13:44,197 INFO [STDOUT] 10:13:44,197 ERROR UsersDAO:133 - find by property name failed
### direct messages to file hibernate.log ###org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:890)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)



Name and version of the database you are using:
Oracle 10g


The generated SQL (show_sql=true):



Debug level Hibernate log excerpt:


Problems with Session and transaction handling?
The hibernate query is not executing and operating on the closed connection..


Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2008 1:11 pm 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Hi,

I think there must be more exception information in the stacktrace than just this:
Quote:
### direct messages to file hibernate.log ###org.hibernate.exception.GenericJDBCException: could not execute query

In my experience, there is a further inner exception which tells why this GenericJDBCException occurred.

_________________
Carlo
-----------------------------------------------------------
please don't forget to rate if this post helped you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2008 5:35 am 
Newbie

Joined: Fri Sep 26, 2008 12:56 am
Posts: 3
yeah..after that it is showing the hql and apprelated stuffs from where it is throwing those.....due u need all those..????


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