Page 1 of 1

Querying OMERO to find a unique file

PostPosted: Wed Jan 26, 2011 4:00 pm
by icaoberg
I am trying to query the database using the suggested query/param objects
Code: Select all
query = session.getQueryService()
iid = 4628
set = "slf34"
filename = 'iid' + str(iid) + '_' + set + '.h5';

params = omero.sys.ParametersI()
params.addString( "file", filename );
query_string = "select f.id from originalfile f where f.name = :file";

In [15]: result = query.findByQuery( query_string, params );
---------------------------------------------------------------------------
QueryException                            Traceback (most recent call last)

/afs/cs.cmu.edu/user/bhcho/demo/<ipython console> in <module>()

/usr0/local/omero.server/OMERO.server-Beta-4.2.1/lib/python/omero_api_IQuery_ice.pyc in findByQuery(self, query, params, _ctx)
    130
    131         def findByQuery(self, query, params, _ctx=None):
--> 132             return _M_omero.api.IQuery._op_findByQuery.invoke(self, ((query, params), _ctx))
    133
    134         def findByQuery_async(self, _cb, query, params, _ctx=None):

QueryException: exception ::omero::QueryException
{
    serverStackTrace = ome.services.query.QueryException: Illegal query:select f.id from originalfile f where f.name = :file
originalfile is not mapped [select f.id from originalfile f where f.name = :file]
   at ome.services.query.StringQuery.buildQuery(StringQuery.java:60)
   at ome.services.query.Query.doInHibernate(Query.java:222)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
   at ome.logic.QueryImpl.execute(QueryImpl.java:141)
   at ome.logic.QueryImpl.findByQuery(QueryImpl.java:337)
   at sun.reflect.GeneratedMethodAccessor713.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at ome.security.basic.EventHandler.invoke(EventHandler.java:157)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at ome.tools.hibernate.ProxyCleanupFilter$Interceptor.invoke(ProxyCleanupFilter.java:231)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at ome.services.util.ServiceHandler.invoke(ServiceHandler.java:111)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy52.findByQuery(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor713.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at ome.security.basic.BasicSecurityWiring.invoke(BasicSecurityWiring.java:83)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at ome.services.blitz.fire.AopContextInitializer.invoke(AopContextInitializer.java:40)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy52.findByQuery(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor997.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at ome.services.blitz.util.IceMethodInvoker.invoke(IceMethodInvoker.java:179)
   at ome.services.throttling.Callback.run(Callback.java:56)
   at ome.services.throttling.InThreadThrottlingStrategy.callInvokerOnRawArgs(InThreadThrottlingStrategy.java:56)
   at ome.services.blitz.impl.AbstractAmdServant.callInvokerOnRawArgs(AbstractAmdServant.java:136)
   at ome.services.blitz.impl.QueryI.findByQuery_async(QueryI.java:92)
   at omero.api._IQueryTie.findByQuery_async(_IQueryTie.java:113)
   at omero.api._IQueryDisp.___findByQuery(_IQueryDisp.java:342)
   at omero.api._IQueryDisp.__dispatch(_IQueryDisp.java:508)
   at IceInternal.Incoming.invoke(Incoming.java:159)
   at Ice.ConnectionI.invokeAll(ConnectionI.java:2037)
   at Ice.ConnectionI.message(ConnectionI.java:972)
   at IceInternal.ThreadPool.run(ThreadPool.java:577)
   at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
   at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:971)

    serverExceptionClass = ome.services.query.QueryException
    message = Illegal query:select f.id from originalfile f where f.name = :file
originalfile is not mapped [select f.id from originalfile f where f.name = :file]
}


when i query the sql database i can find this file. i am not sure what am i doing wrong.

Re: Querying OMERO to find a unique file

PostPosted: Wed Jan 26, 2011 4:22 pm
by jmoore
You must use the proper capitalization for OriginalFile.
~J.