-->
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 by Example
PostPosted: Fri Feb 27, 2004 1:05 pm 
Newbie

Joined: Fri Feb 27, 2004 1:01 pm
Posts: 4
Hi,
I'm trying to use the Query by Example, but it does not work. It generates good SQL, but throws a JDBC excpetion:
java.sql.SQLException: The data flow is already closed.

Example example = Example.create(value);
result = session.createCriteria(value.getClass()).add(example).list();

Has anybody an Idea?
Simon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Driver problem? BLOB in your example object which is from an older session? Impossible to tell with such a description.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 7:11 am 
Newbie

Joined: Fri Feb 27, 2004 1:01 pm
Posts: 4
Hi,
I'll try to be more precise. I use hibernate-2.1, with an Oracle 8i database.
I did several tests, and here is what I can say.
To open and close sessions, I use the class HibernateUtil given in the hibernate distrib.

Here is the code, in a method where I pass a parameter value of type Object.

List result = null;
try {
// this is to use find method
String request = "from " + value.getClass().getName();
// this is to use criteria
Example example = Example.create(value);

net.sf.hibernate.Session session = HibernateUtil.currentSession();
// this work properly
result = session.find(request);
HibernateUtil.closeSession();
session = HibernateUtil.currentSession();
// this work properly
result = session.find(request);
HibernateUtil.closeSession();

session = HibernateUtil.currentSession();
// this throws an exception.
result = session.createCriteria(value.getClass()).add(example).list();
HibernateUtil.closeSession();

} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

I can open and close sessions as long as I use the "find" method. I can't close a session if I want to use createCriteria: if one session has been closed, it throws an excpetion even if I get and open a new one. I can't figure out why.
The exception is this one and is thrown "after" the database has been queried.

net.sf.hibernate.JDBCException: SQLException occurred
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3443)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:177)

Caused by: java.sql.SQLException: Le flux de donn


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 8:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
maybe a connection pool problem try this

<property name="dbcp.maxActive">30</property>
<property name="dbcp.whenExhaustedAction">10</property>
<property name="dbcp.maxWait">120000</property>
<property name="dbcp.maxIdle">1</property>
<property name="dbcp.minIdle">0</property>
<property name="dbcp.ps.maxActive">10</property>
<property name="dbcp.ps.whenExhaustedAction">10</property>
<property name="dbcp.ps.maxWait">120000</property>
<property name="dbcp.ps.maxIdle">100</property>
<property name="dbcp.validationQuery">select 1 from dual</property>
<property name="dbcp.testOnBorrow">true</property>
<property name="dbcp.testOnReturn">false</property>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 1:09 pm 
Newbie

Joined: Fri Feb 27, 2004 1:01 pm
Posts: 4
Maybe, my test application now work with this parameters
<property name="dbcp.maxActive">30</property>
<property name="dbcp.whenExhaustedAction">0</property>
<property name="dbcp.maxWait">120000</property>
<property name="dbcp.maxIdle">1</property>
<property name="dbcp.testOnBorrow">true</property>
<property name="dbcp.testOnReturn">false</property>
<property name="dbcp.ps.maxActive">10</property>
<property name="dbcp.ps.whenExhaustedAction">0</property>
<property name="dbcp.ps.maxWait">120000</property>
<property name="dbcp.ps.maxIdle">100</property>
(whenExhaustedAction can't take 10 for value), but I don't exactly understand why. The problem is that I did put the parameters on the data source used by my real application which is a struts application, but it still does not work. In fact it works for some classes but not for others. This behavior is very strange. I think I'll soon surrender and use the HQL even if was not my first choice.
Simon.


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.