5 Replies Latest reply on Feb 9, 2009 5:57 PM by Andrew Fuqua

    Error creating sessionfactory when using HQL Editor

    Andrew Fuqua Newbie

      My project and all queries run fine when deployed to the server, but for some reason the exception below is thrown in the HQL editor. Do you know how to get rid of this so I can use the HQL editor again? This HQL editor used to work before I enabled query caching. (see persistence.xml below). Now, even if I disable query caching and restore persistence.xml to the way it was before, the HQL Editor still throws this exception. I have also tried explicitly enabling the second-level cache in persistence.xml to no avail.

      I have seen forum posts on this subject from as long ago as 2 years. There was not a clear resolution, so I am posting again. It seems like a class loading issue, but I have no idea how to fix it. I think I am posting this in the right forum, but if not, please kindly direct me to the appropriate place. Thank you.

      Exception: (Title: "Problems while creating sessionfactory")

      org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
       at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21)
       at org.hibernate.cache.UpdateTimestampsCache.<init>(UpdateTimestampsCache.java:42)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:337)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
       at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
       at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:399)
       at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
       at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:93)
       at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:394)
       at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:43)
       at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:99)
       at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:105)
       at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234)
       at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
      



      Persistence.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for dev profile -->
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
      
       <persistence-unit name="a1">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/a1Datasource</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.format_sql" value="true"/>
       <property name="hibernate.cache.use_query_cache" value="true"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/a1EntityManagerFactory"/>
       </properties>
       </persistence-unit>
      
      </persistence>