-->
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.  [ 6 posts ] 
Author Message
 Post subject: session.filter + query.list()
PostPosted: Wed Sep 22, 2004 8:31 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
hi...

i've a problem i need to obtain something like this:


Hibernate version: 2.1

Mapping documents: not necessary

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

List list = session.createCriteria(...).list();
list = session.filter(list, "where x > 1");

the problem is net.sf.hibernate.QueryException: The collection was
unreferenced

how can i resolve my problem?

thanks.

Marco

Full stack trace of any exception that occurs:
net.sf.hibernate.QueryException: The collection was unreferenced
at net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3446)
at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3509)
at net.sf.hibernate.impl.FilterImpl.list(FilterImpl.java:42)
at com.coginfo.framework.action.LookUpAction.executeView(LookUpAction.java:95)
at com.coginfo.framework.action.ViewListAction.performView(ViewListAction.java:96)
at com.coginfo.framework.action.ViewListAction.search(ViewListAction.java:55)
at com.coginfo.framework.action.LookUpAction.lookUp(LookUpAction.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at com.coginfo.asc.struts.AscDispatchActionNoSession.execute(AscDispatchActionNoSession.java:47)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:506)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Unknown Source)


Name and version of the database you are using:
Oracle 9.02


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 22, 2004 8:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Code between sessionFactory.openSession() and session.close():
means "how are you getting and using the session"...

there must be something else than
Code:
List list = session.createCriteria(...).list();
list = session.filter(list, "where x > 1");

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 22, 2004 8:40 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
public class HibernateDAOServiceImpl extends AscDAOService{

private static final ThreadLocal currentSession = new ThreadLocal();
private static SessionFactory sessionFactory;
private static Configuration configuration;

public void init(HttpServlet servlet,InputStream fileConfig) throws DAOServiceException{
/** Importante chiamare il metodo init*/
super.init(servlet,fileConfig);
try {
if (sessionFactory == null){
configuration = new Configuration().configure();
setSessionFactory(configuration.buildSessionFactory());
detailLog.info("Librerie DAO inizializzate con successo");
}
}
catch (HibernateException ex) {
detailLog.error("Errore in fase di inizializzazione librerie DAO: " + ex.toString());
throw new DAOServiceException(IConstants.DAO_ERROR_PREFIS,new String[]{ex.toString()});
}
}

/**
* Restituisce un iterator di PersistentClass (class mapping), ossia la struttura di una tabella
* @return
*/
public Iterator getMappings(){
return configuration.getClassMappings();
}

/**
* Restituisce il PersistentClass (class mapping) della classe passata, ossia il bean della tabella da gestire
* @param classToSearch
* @return
*/
public PersistentClass getMapping(Class classToSearch){
return configuration.getClassMapping(classToSearch);
}

/**
* Restituisce la sessione corrente al DB
* @return
*/
protected static ThreadLocal getCurrentSession() {
return currentSession;
}

/*
* Get sessionFactory
* @return
*/
protected static SessionFactory getSessionFactory() {
return sessionFactory;
}

/**
* Imposta l'oggetto session factory
* @param factory
*/
protected static void setSessionFactory(SessionFactory factory) {
sessionFactory = factory;
}

/***
* Returns the current <code>Session</code> for the current thread.
* If none available, it creates the necessary and stores it via <code>ThreadLocal</thread>.
*/
public static Session currentSession() throws DAOServiceException {
Session session = (Session)getCurrentSession().get();
if (null == session) {
try {
if (getSessionFactory() != null){
session = getSessionFactory().openSession();
getCurrentSession().set(session);
}
}
catch (HibernateException he) {
detailLog.error("Errore in fase currentSession: " + he.toString());
throw new DAOServiceException(IConstants.DAO_ERROR_PREFIS,new String[]{he.toString()});
}
}
return session;
}

/***
* Flushes and closes <code>Session</code> passed.
*/
public static void closeSession(Session session) throws HibernateException{
if (null != session) {
session.close();
getCurrentSession().set(null);
}
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 3:35 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
plz some one help me...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 3:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
most likely it is not a persistent collection you are applying filter() to.

the exception tells the story: the collection is not referenced by any entity managed by that session


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 4:05 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
ok... but any solution...

i must filter again a collection resulted form a criteria

any solution?.


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