[jboss-user] [EJB 3.0] - SQLGrammarException: could not load an entity

VictoriaOnSand do-not-reply at jboss.com
Wed Mar 7 09:32:20 EST 2007


Hi,

When using JBoss 4.0.5 with Oracle an exception occured while quering a quite complex object from database. Hibernate constructs a query that is not compatible with Oracle: ' select .... from T_COLUMN_TYPE as a14 ..'. It looks like that an other than Oracle9Dialect is taken somewhere.


  | 2007-03-07 14:16:47,980 INFO  [STDOUT] Hibernate: select tabletype0_.name as name9_1_, columns1_.NAME as NAME3_, columntype2_.COLUMN_NAME as COLUMN2_3_, (select a14.COLUMN_NAME from T_COLUMN_TYPE as a14 where a14.COLUMN_NAME=columns1_.COLUMN_NAME) as formula0_3_, columntype2_.COLUMN_NAME as COLUMN1_2_0_, 
  | columntype2_.PREDICTOR_INTERNAL_NAME as PREDICTOR2_2_0_, columntype2_.DATA_TYPE as DATA3_2_0_ from T_Table_Type tabletype0_ left outer join T_TABLE_COLUMN_TYPE co
  | lumns1_ on tabletype0_.name=columns1_.NAME left outer join T_COLUMN_TYPE columntype2_ on columns1_.COLUMN_NAME=columntype2_.COLUMN_NAME where tabletype0_.na
  | me=?
  | 2007-03-07 14:16:47,993 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 907, SQLState: 42000
  | 2007-03-07 14:16:47,993 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-00907: Rechte Klammer fehlt
  | 
  | 2007-03-07 14:16:47,998 INFO  [org.hibernate.event.def.DefaultLoadEventListener] Error performing load command
  | org.hibernate.exception.SQLGrammarException: could not load an entity: [de.web.mf.tgp.tgpmanager.entity.TableType#PostScore.WEB_AFFINITY.wirtschaft]
  |         at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
  |         at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
  |         at org.hibernate.loader.Loader.loadEntity(Loader.java:1798)
  |         at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
  |         at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
  |         at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2977)
  |         at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:393)
  |         at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:374)
  |         at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:137)
  |         at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:193)
  |         at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101)
  |         at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
  |         at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
  |         at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
  |         at org.hibernate.type.EntityType.resolve(EntityType.java:303)
  |         at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
  |         at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
  |         at org.hibernate.loader.Loader.doQuery(Loader.java:717)
  |         at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
  |         at org.hibernate.loader.Loader.doList(Loader.java:2144)
  |         at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
  |         at org.hibernate.loader.Loader.list(Loader.java:2023)
  |         at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
  |         at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
  |         at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
  |         at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
  |         at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
  |         at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:80)
  |         at de.web.mf.tgp.tgpmanager.persistence.PersistenceManager.findModelByName(PersistenceManager.java:145)
  | 

The following persistence.xml file defines to use Oracle9Dialect. 

persistence.xml:

  | <persistence>
  |   <persistence-unit name="tgp">
  |     <jta-data-source>java:/OracleDS_TGP</jta-data-source>
  |     <properties>
  |       <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect" />
  |       <property name="hibernate.hbm2ddl.auto" value="create-drop" />
  |       <property name="hibernate.cache.use_query_cache" value="true" />
  |       <property name="hibernate.show_sql" value="true" />
  |       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
  |     </properties>
  |   </persistence-unit>
  | </persistence>
  | 


While deploying the ear a strange sequence of log statements are shown:
"Using dialect: org.hibernate.dialect.HSQLDialect". Later down you can see that Oracle JDBC driver gets inititialized.


  | 2007-03-07 14:08:47,865 INFO  [org.hibernate.cfg.AnnotationBinder] Binding entity from annotated class: de.web.mf.tgp.tgpmanager.entity.ThreshholdNullRule
  | 2007-03-07 14:08:47,864 INFO  [org.hibernate.cfg.annotations.EntityBinder] Bind entity de.web.mf.tgp.tgpmanager.entity.ThreshholdNullRule on table T_Threshh
  | old_Null_Rule
  | 2007-03-07 14:08:48,119 INFO  [org.hibernate.dialect.Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
  | 2007-03-07 14:08:48,133 INFO  [org.hibernate.dialect.Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
  | 2007-03-07 14:08:48,141 INFO  [org.hibernate.cfg.annotations.CollectionBinder] Mapping collection: de.web.mf.tgp.tgpmanager.entity.Project.models -> T_MODEL
  | 2007-03-07 14:08:48,141 INFO  [org.hibernate.cfg.annotations.CollectionBinder] Mapping collection: de.web.mf.tgp.tgpmanager.entity.User.models -> T_MODEL
  | 2007-03-07 14:08:48,143 INFO  [org.hibernate.cfg.annotations.CollectionBinder] Mapping collection: de.web.mf.tgp.tgpmanager.entity.Mandator.models -> T_MODE
  | L
  | 2007-03-07 14:08:48,144 INFO  [org.hibernate.cfg.annotations.CollectionBinder] Mapping collection: de.web.mf.tgp.tgpmanager.entity.TableType.tableProcessing
  | Rules -> T_Table_Processing_Rule
  | 2007-03-07 14:08:49,470 INFO  [org.hibernate.connection.ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDa
  | taSourceConnectionProvider
  | 2007-03-07 14:08:49,485 INFO  [org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider] Using provided datasource
  | 2007-03-07 14:08:49,526 INFO  [org.hibernate.cfg.SettingsFactory] RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
  | With the Partitioning, OLAP and Oracle Data Mining options
  | JServer Release 9.2.0.6.0 - Production
  | 2007-03-07 14:08:49,528 INFO  [org.hibernate.cfg.SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.2.0.2.0
  | 2007-03-07 14:08:49,541 INFO  [org.hibernate.dialect.Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect
  | 2007-03-07 14:08:49,545 INFO  [org.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
  | 


I am using JBoss 4.0.5 which comes with EJB3-RC7. When trying RC9 the problem still remains. 

Could somebody what's wrong?




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4025805#4025805

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4025805



More information about the jboss-user mailing list