Hey all,
Perhaps someone can help me with this problem.
I've defined a query in my .hbm file:
Code:
<query name="org.pentaho.repository.content.findContentLocationByPath">
<![CDATA[
from org.pentaho.repository.content.ContentLocation cLoc where cLoc.dirPath = :inPath
]]>
</query>
The query definitely gets interpreted - here's the debugging output:
Code:
22:27:08,272 DEBUG QueryTranslatorImpl:207 - parse() - HQL:
from org.pentaho.repository.content.ContentLocation cLoc where cLoc.dirPath = :inPath
22:27:08,302 DEBUG AST:223 - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| \-[FROM] 'from'
| \-[RANGE] 'RANGE'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[IDENT] 'org'
| | | | | \-[IDENT] 'pentaho'
| | | | \-[IDENT] 'repository'
| | | \-[IDENT] 'content'
| | \-[IDENT] 'ContentLocation'
| \-[ALIAS] 'cLoc'
\-[WHERE] 'where'
\-[EQ] '='
+-[DOT] '.'
| +-[IDENT] 'cLoc'
| \-[IDENT] 'dirPath'
\-[COLON] ':'
\-[IDENT] 'inPath'
22:27:08,302 DEBUG ErrorCounter:68 - throwQueryException() : no errors
22:27:08,362 DEBUG HqlSqlBaseWalker:127 - query() << begin, level = 1
22:27:08,543 DEBUG FromElement:89 - FromClause{level=1} : org.pentaho.repository.content.ContentLocation (cLoc) -> contentloc0_
22:27:08,543 DEBUG FromReferenceNode:48 - Resolved : cLoc -> contentloc0_.CONTENTID
22:27:08,543 DEBUG DotNode:490 - getDataType() : dirPath -> org.hibernate.type.StringType@1ed1b0b
22:27:08,543 DEBUG FromReferenceNode:48 - Resolved : cLoc.dirPath -> contentloc0_.DIRPATH
22:27:08,553 DEBUG HqlSqlBaseWalker:132 - query() : finishing up , level = 1
22:27:08,553 DEBUG HqlSqlWalker:362 - processQuery() : ( SELECT ( FromClause{level=1} CONTENTLOCATION contentloc0_ ) ( where ( = ( contentloc0_.DIRPATH contentloc0_.CONTENTID dirPath ) ? ) ) )
22:27:08,563 DEBUG HqlSqlWalker:452 - Derived SELECT clause created.
22:27:08,593 DEBUG JoinProcessor:112 - Using FROM fragment [CONTENTLOCATION contentloc0_]
22:27:08,593 DEBUG HqlSqlBaseWalker:135 - query() >> end, level = 1
But, when I try to load the query using this code:
Code:
Session session = HibernateUtil.getSession();
Query qry = session.getNamedQuery("org.pentaho.repository.content.findContentLocationByPath");
qry.setString("inPath", thePath);
Object rtn = qry.uniqueResult();
return (ContentLocation)rtn;
I get this exception:
Code:
org.hibernate.MappingException: Named query not known: org.pentaho.repository.content.findContentLocationByPath
at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1027)
at org.pentaho.repository.content.ContentRepository.getContentLocationByPath(ContentRepository.java:69)
at com.pentaho.testharness.Testit.testCreateContentItem(Testit.java:635)
at com.pentaho.testharness.Testit.main(Testit.java:76)
Exception in thread "main"
Anyone know what the problem is here?
Thanks,
Marc