I query, get a List of results, then (try to) filter those results. This always produces:
[java] net.sf.hibernate.QueryException: The collection was unreferenced
[java] at net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3408)
[java] at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3471)
[java] at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3366)
[java] at com.publishworks.merchandise.ItemMeta.filterForAttributeName(ItemMeta.java:24)
[java] at com.publishworks.hibernate.test.Test1.ReebokTest(Test1.java:99)
[java] at com.publishworks.hibernate.test.Test1.main(Test1.java:189)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:233)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:170)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:699)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:206)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:115)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
[java] at org.apache.tools.ant.Task.perform(Task.java:401)
[java] at org.apache.tools.ant.Target.execute(Target.java:338)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:365)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:669)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:220)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
Code:
public static ItemMeta filterForAttributeName(Collection itemMetas, String attribName)
throws HibernateException
{
return (ItemMeta) CollectionUtils.get( HibernateUtil.currentSession().filter(itemMetas,
"where this.internal=false AND this.attribName=?", attribName, Hibernate.STRING), 0);
}
static List fetchFacets(DataSlice ds) throws HibernateException
{
return HibernateUtil.currentSession()
.find("select from ItemMeta as im where im.indexed=true AND im.dataSlice=?",
ds, Hibernate.entity(DataSlice.class));
}
public static void main(String[] args) throws HibernateException, SQLException
{
Collection facets = ds.getItemFacets();
ItemMeta sectionFacet = ItemMeta.filterForAttributeName(facets, "fts_category");
}
Am I calling this wrong? Is this a known bug? Is there a work-around?