Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.05
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping default-lazy="false">
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="za.co.telkom.num.hibernate.NumIpnumberblock"
table="NUM_IPNUMBERBLOCK"
lazy="false"
>
...
...
...
<!-- Filters -->
<filter name = "FunctionFilter"
condition = "networkid in (select num_network.networkid from num_function, num_network_function, num_network, num_rolefunction where num_rolefunction.roleid = :roleId and num_rolefunction.functionid = :functionId and num_rolefunction.functionid = num_function.functionid and num_function.functionid = num_network_function.function_id and num_network_function.network_id = num_network.networkid)"
/>
</class>
<!-- No filterdef (hibernate-ALL-filter-def.txt) found. -->
<filter-def name="FunctionFilter">
<filter-param name="functionId" type="long"/>
<filter-param name="roleId" type="long"/>
</filter-def>
Code between sessionFactory.openSession() and session.close():
vSession.enableFilter("FunctionFilter");
vSession.getEnabledFilter("FunctionFilter").setParameter("functionId", 3L);
vSession.getEnabledFilter("FunctionFilter").setParameter("roleId", 3L);
Query vQuery = vSession.createQuery("from NumIpnumberblock");
return vQuery.list();
Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at CriteriaMaker.getIPBlocks(CriteriaMaker.java:45)
at CriteriaMaker.main(CriteriaMaker.java:156)
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
at oracle.jdbc.oci8.OCIDBAccess.parseExecuteDescribe(OCIDBAccess.java:1255)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
select numipnumbe0_.BLOCKID as BLOCKID, numipnumbe0_.DATECREATED as DATECREA2_6_, numipnumbe0_.BLOCKSIZE as BLOCKSIZE6_, numipnumbe0_.NOTES as NOTES6_, numipnumbe0_.AFRINICAPPROVEDTODELETE as AFRINICA5_6_, numipnumbe0_.NETWORKLAYERID as NETWORKL6_6_, numipnumbe0_.SUBSERVICEID as SUBSERVI7_6_, numipnumbe0_.NUMBERROUTABILITYID as NUMBERRO8_6_, numipnumbe0_.NETWORKID as NETWORKID6_, numipnumbe0_.PARENTBLOCKID as PARENTB10_6_, numipnumbe0_.REGIONID as REGIONID6_, numipnumbe0_.OWNER_NUMUSERID as OWNER12_6_, numipnumbe0_.CREATED_BY as CREATED13_6_, numipnumbe0_.FORWARDED_NUMUSERID as FORWARDED14_6_, numipnumbe0_.LINKTYPEID as LINKTYPEID6_, numipnumbe0_.NUMFAMILYID as NUMFAMI16_6_, numipnumbe0_.SERVICEID as SERVICEID6_, numipnumbe0_.RECEVEDFROM as RECEVED18_6_, numipnumbe0_.CUSTOMERID as CUSTOMERID6_ from NUM_IPNUMBERBLOCK numipnumbe0_ where numipnumbe0_.networkid in (select num_network.networkid from num_function, numipnumbe0_.num_network_function, num_network, numipnumbe0_.num_rolefunction where num_rolefunction.roleid = ? and num_rolefunction.functionid = ? and num_rolefunction.functionid = num_function.functionid and num_function.functionid = num_network_function.function_id and num_network_function.network_id = num_network.networkid)
-------------------------------------------------------------
The problem seems to be in the generated sql (the from clause of the correlated query to be exact, which says:
Code:
num_function, numipnumbe0_.num_network_function, num_network, numipnumbe0_.num_rolefunction
However, my definition in the XML says:
Code:
from num_function, num_network_function, num_network, num_rolefunction
Any ideas as to how this could have happened?