Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Spring: AnnotationSessionFactoryBean, Hibernate-Dialect AutoDetection
    primarykey
    data
    text
    <p>I use the following spring application context:</p> <pre><code>&lt;!-- Hibernate session factory --&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;!-- &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt; --&gt; &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt; &lt;prop key="hibernate.max_fetch_depth"&gt;${hibernate.max_fetch_depth}&lt;/prop&gt; &lt;prop key="hibernate.cache.use_second_level_cache"&gt;${hibernate.cache.use_second_level_cache}&lt;/prop&gt; &lt;prop key="hibernate.cache.use_query_cache"&gt;${hibernate.cache.use_query_cache}&lt;/prop&gt; &lt;prop key="hibernate.cache.provider_class"&gt;${hibernate.cache.provider}&lt;/prop&gt; &lt;prop key="hibernate.connection.pool_size"&gt;10&lt;/prop&gt; &lt;prop key="hibernate.jdbc.batch_size"&gt;1000&lt;/prop&gt; &lt;prop key="hibernate.bytecode.use_reflection_optimizer"&gt;true&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="annotatedClasses"&gt; &lt;list&gt; ... &lt;/list&gt; &lt;/property&gt; &lt;property name="schemaUpdate" value="${hibernate.schemaUpdate}"/&gt; &lt;/bean&gt; </code></pre> <p><strong>Then problem is: Although Hibernate should support Dialect-Autodetection this code doesnt work:</strong> Uppon Application-Init the following exception is thrown:</p> <pre><code>org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect. at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:256) at org.hibernate.dialect.Dialect.getDialect(Dialect.java:234) at org.hibernate.dialect.Dialect.getDialect(Dialect.java:249) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$3.doInHibernate(LocalSessionFactoryBean.java:957) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.updateDatabaseSchema(LocalSessionFactoryBean.java:953) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterSessionFactoryCreation(LocalSessionFactoryBean.java:843) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:213) </code></pre> <p><em>I can avoid this exception by uncommenting the hibernate.dialect property. Why do I have to do this? Why cant hibernate just autodetect the dialect like it is supposed to?</em></p> <p>I want do remove the dialect-property to solve <a href="https://stackoverflow.com/questions/1432193/java-dbunitils-spring-different-hibernate-dialect">this</a> problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload