1 Reply Latest reply on Sep 24, 2007 8:00 PM by Arbi Sookazian

    Hibernate Dialect must be explicitly set

    Arbi Sookazian Master

      SEAM 1.2.1.GA
      JBOSS 4.0.5.GA

      Trying to exec a DAO method in a Seam-gen'd Seam app using JSF (MyFaces xhtml), SFSB, DAO, and Entity bean.

      getting following stack trace when I click the commandLink on JSF to exec the action method on the SFSB:

      Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
       at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
       at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
       at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:409)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:691)


      I added the line "hibernate.dialect" line to the persistence.xml below and still getting the same exception after restarting the server and deploying app. I viewed the persistence.xml file in the JAR's meta-inf folder and it matches the one below. Why is it not reading/picking up the new version??? thx.

      <?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="SHIMS">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/SHIMSDatasource</jta-data-source>
      
       <properties>
       <!-- commented hibernate auto validate due to errors upon deployment (validates the db structure at start-up) -->
       <!-- <property name="hibernate.hbm2ddl.auto" value="validate"/> -->
       <!-- AS 09-24-07 - added hibernate.dialect property due to error during runtime stating "Hibernate Dialect must be explicitly set" -->
       <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
       <property name="hibernate.cache.use_query_cache" value="true"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/SHIMSEntityManagerFactory"/>
       <property name="hibernate.default_catalog" value="boSHIMS"/>
       <property name="hibernate.default_schema" value=""/>
       </properties>
      
       </persistence-unit>
      
      </persistence>


      SHIMSDatasource.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
      
       <local-tx-datasource>
       <jndi-name>SHIMSDatasource</jndi-name>
       <connection-url>jdbc:sqlserver://CORG0DV01:1433;databaseName=boSHIMS</connection-url>
       <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
       <user-name>_AppUser_JavaTestAcct</user-name>
       <password>JavaTestAcct</password>
      <!--
       <exception-sorter-class-name>
       org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
       </exception-sorter-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
      -->
       </local-tx-datasource>
      
      </datasources>


        • 1. Re: Hibernate Dialect must be explicitly set
          Arbi Sookazian Master

          I changed the persistence-dev.xml to the following and it fixed all issues. I don't know why seam-gen creates a version with more parameters/properties that confuses JBoss...

          <?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="shimsPUN">
           <provider>org.hibernate.ejb.HibernatePersistence</provider>
           <jta-data-source>java:/SHIMSDatasource</jta-data-source>
           </persistence-unit>
          
          </persistence>