I have a very strange problem for me but may very simple for you guys.
I created tables using ant task schemaexport and loaded some data. I am sure the table and data was there because I can see them from HSQLDM.
but when I tried to load it from my program, it tell me mytable
(NCBC_ESOURCE or PUBLIC.NCBC_RESOURCE) was not mapped.
but the log and the validator tell me that the table was there!
any help be very welcome.
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<!-- Generated file - Do not edit! -->
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="hbm2ddl.auto">validate</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">false</property>
<property name="connection.username">sa</property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost:9005/ncbcitools</property>
<!-- mapping files -->
<mapping resource="edu/ucla/loni/ccb/itools/model/NcbcResource.hbm.xml"/>
<mapping resource="edu/ucla/loni/ccb/itools/model/ResourceReview.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-mapping (View Source for full doctype...)>
- <hibernate-mapping default-cascade="none" default-access="property" default-lazy="true" auto-import="true">
- <class name="edu.ucla.loni.ccb.itools.model.NcbcResource" table="ncbc_resource" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" select-before-update="false" optimistic-lock="version">
- <id name="id" column="id" type="int" unsaved-value="null">
- <generator class="native">
- <!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-NcbcResource.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property name="center" type="java.lang.String" update="true" insert="true" column="center" unique="false" optimistic-lock="true" lazy="false" generated="never" />
- <map name="allProperties" lazy="false" sort="unsorted" cascade="all" mutable="true" inverse="false" optimistic-lock="true" embed-xml="true">
<key column="resouce_id" on-delete="noaction" />
<index column="descriptor_name" type="string" length="50" />
<element column="descriptor_value" type="string" length="800" not-null="false" unique="false" />
</map>
- <!-- To add non XDoclet property mappings, create a file named
hibernate-properties-NcbcResource.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Collection rv = new ArrayList(0);
Session session = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
rv = session.createQuery("from PUBLIC.NCBC_RESOURCE where center= ? ")
.setString(0, center).list();
tx.commit();
} catch (Exception e) {
logger.warn(e,e);
}
Full stack trace of any exception that occurs:
2006-12-17 22:30:51,687 WARN [edu.ucla.loni.ccb.itools.dao.db.DatabaseResourceDao] - <org.hibernate.hql.ast.QuerySyntaxException: PUBLIC.NCBC_RESOURCE is not mapped. [from PUBLIC.NCBC_RESOURCE where center= ? ]>
org.hibernate.hql.ast.QuerySyntaxException: PUBLIC.NCBC_RESOURCE is not mapped. [from PUBLIC.NCBC_RESOURCE where center= ? ]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:157)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:265)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.createQuery(Unknown Source)
at edu.ucla.loni.ccb.itools.dao.db.DatabaseResourceDao.load(DatabaseResourceDao.java:43)
at edu.ucla.loni.ccb.itools.view.ResourceIndexTree.load(ResourceIndexTree.java:115)
at edu.ucla.loni.ccb.itools.view.NcbcResourceIndexTree.load(NcbcResourceIndexTree.java:29)
at edu.ucla.loni.ccb.itools.view.ContentPane.init(ContentPane.java:64)
at edu.ucla.loni.ccb.itools.Main.main(Main.java:54)
Caused by: PUBLIC.NCBC_RESOURCE is not mapped.
... 30 more
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
2006-12-17 22:28:10,546 INFO [org.hibernate.cfg.Environment] - <Hibernate 3.1.3>
2006-12-17 22:28:10,562 INFO [org.hibernate.cfg.Environment] - <hibernate.properties not found>
2006-12-17 22:28:10,562 INFO [org.hibernate.cfg.Environment] - <using CGLIB reflection optimizer>
2006-12-17 22:28:10,562 INFO [org.hibernate.cfg.Environment] - <using JDK 1.4 java.sql.Timestamp handling>
2006-12-17 22:28:10,703 INFO [org.hibernate.cfg.Configuration] - <configuring from resource: /hibernate.cfg.xml>
2006-12-17 22:28:10,718 INFO [org.hibernate.cfg.Configuration] - <Configuration resource: /hibernate.cfg.xml>
2006-12-17 22:28:10,875 ERROR [org.hibernate.util.DTDEntityResolver] - <Don't use old DTDs, read the Hibernate 3.x Migration Guide!>
2006-12-17 22:28:11,171 INFO [org.hibernate.cfg.Configuration] - <Reading mappings from resource: edu/ucla/loni/ccb/itools/model/NcbcResource.hbm.xml>
2006-12-17 22:28:11,359 INFO [org.hibernate.cfg.HbmBinder] - <Mapping class: edu.ucla.loni.ccb.itools.model.NcbcResource -> ncbc_resource>
2006-12-17 22:28:11,406 INFO [org.hibernate.cfg.HbmBinder] - <Mapping collection: edu.ucla.loni.ccb.itools.model.NcbcResource.allProperties -> allProperties>
2006-12-17 22:28:11,406 INFO [org.hibernate.cfg.Configuration] - <Reading mappings from resource: edu/ucla/loni/ccb/itools/model/ResourceReview.hbm.xml>
2006-12-17 22:28:11,468 INFO [org.hibernate.cfg.HbmBinder] - <Mapping class: edu.ucla.loni.ccb.itools.model.ResourceReview -> resource_review>
2006-12-17 22:28:11,468 INFO [org.hibernate.cfg.Configuration] - <Configured SessionFactory: null>
2006-12-17 22:28:11,609 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - <Using Hibernate built-in connection pool (not for production use!)>
2006-12-17 22:28:11,609 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - <Hibernate connection pool size: 20>
2006-12-17 22:28:11,609 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - <autocommit mode: false>
2006-12-17 22:28:11,625 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - <using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost:9005/ncbcitools>
2006-12-17 22:28:11,625 INFO [org.hibernate.connection.DriverManagerConnectionProvider] - <connection properties: {user=sa}>
2006-12-17 22:28:13,718 INFO [org.hibernate.cfg.SettingsFactory] - <RDBMS: HSQL Database Engine, version: 1.8.0>
2006-12-17 22:28:13,718 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC driver: HSQL Database Engine Driver, version: 1.8.0>
2006-12-17 22:28:13,796 INFO [org.hibernate.dialect.Dialect] - <Using dialect: org.hibernate.dialect.HSQLDialect>
2006-12-17 22:28:13,875 INFO [org.hibernate.transaction.TransactionFactoryFactory] - <Using default transaction strategy (direct JDBC transactions)>
2006-12-17 22:28:13,875 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - <No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)>
2006-12-17 22:28:13,875 INFO [org.hibernate.cfg.SettingsFactory] - <Automatic flush during beforeCompletion(): disabled>
2006-12-17 22:28:13,875 INFO [org.hibernate.cfg.SettingsFactory] - <Automatic session close at end of transaction: disabled>
2006-12-17 22:28:13,875 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC batch size: 15>
2006-12-17 22:28:13,875 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC batch updates for versioned data: disabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Scrollable result sets: enabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC3 getGeneratedKeys(): disabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Connection release mode: auto>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Default batch fetch size: 1>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Generate SQL with comments: disabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Order SQL updates by primary key: disabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory>
2006-12-17 22:28:13,890 INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - <Using ASTQueryTranslatorFactory>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Query language substitutions: {}>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Second-level cache: enabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Query cache: disabled>
2006-12-17 22:28:13,890 INFO [org.hibernate.cfg.SettingsFactory] - <Cache provider: org.hibernate.cache.NoCacheProvider>
2006-12-17 22:28:13,906 INFO [org.hibernate.cfg.SettingsFactory] - <Optimize cache for minimal puts: disabled>
2006-12-17 22:28:13,906 INFO [org.hibernate.cfg.SettingsFactory] - <Structured second-level cache entries: disabled>
2006-12-17 22:28:13,906 INFO [org.hibernate.cfg.SettingsFactory] - <Statistics: disabled>
2006-12-17 22:28:13,906 INFO [org.hibernate.cfg.SettingsFactory] - <Deleted entity synthetic identifier rollback: disabled>
2006-12-17 22:28:13,906 INFO [org.hibernate.cfg.SettingsFactory] - <Default entity-mode: pojo>
2006-12-17 22:28:13,968 INFO [org.hibernate.impl.SessionFactoryImpl] - <building session factory>
2006-12-17 22:28:14,734 INFO [org.hibernate.impl.SessionFactoryObjectFactory] - <Not binding factory to JNDI, no JNDI name configured>
2006-12-17 22:28:14,734 INFO [org.hibernate.tool.hbm2ddl.SchemaValidator] - <Running schema validator>
2006-12-17 22:28:14,734 INFO [org.hibernate.tool.hbm2ddl.SchemaValidator] - <fetching database metadata>
2006-12-17 22:28:14,765 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - <table found: PUBLIC.ALLPROPERTIES>
2006-12-17 22:28:14,765 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - <columns: [resouce_id, descriptor_name, descriptor_value]>
2006-12-17 22:28:14,765 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - <table found: PUBLIC.NCBC_RESOURCE>
2006-12-17 22:28:14,765 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - <columns: [center, id]>
2006-12-17 22:28:14,765 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - <table found: PUBLIC.RESOURCE_REVIEW>
2006-12-17 22:28:14,765 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - <columns: [totalvote, title, createddate, yesvote, comment, resource_name, author, id, rate]>
2006-12-17 22:30:51,687 WARN [edu.ucla.loni.ccb.itools.dao.db.DatabaseResourceDao] - <org.hibernate.hql.ast.QuerySyntaxException: PUBLIC.NCBC_RESOURCE is not mapped. [from PUBLIC.NCBC_RESOURCE where center= ? ]>
org.hibernate.hql.ast.QuerySyntaxException: PUBLIC.NCBC_RESOURCE is not mapped. [from PUBLIC.NCBC_RESOURCE where center= ? ]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:157)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:265)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.createQuery(Unknown Source)
at edu.ucla.loni.ccb.itools.dao.db.DatabaseResourceDao.load(DatabaseResourceDao.java:43)
at edu.ucla.loni.ccb.itools.view.ResourceIndexTree.load(ResourceIndexTree.java:115)
at edu.ucla.loni.ccb.itools.view.NcbcResourceIndexTree.load(NcbcResourceIndexTree.java:29)
at edu.ucla.loni.ccb.itools.view.ContentPane.init(ContentPane.java:64)
at edu.ucla.loni.ccb.itools.Main.main(Main.java:54)
Caused by: PUBLIC.NCBC_RESOURCE is not mapped.
... 30 more
|