【问题标题】:Disable ONLY_FULL_GROUP_BY in hibernate在休眠中禁用 ONLY_FULL_GROUP_BY
【发布时间】:2017-06-12 21:28:13
【问题描述】:

我需要在休眠中禁用 ONLY_FULL_GROUP_BY。 这是我当前的会话工厂。 我不确定如何在此指定 sql_mode=''。

<bean id="eAgilitySessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="eAgilitysDataSource"/>
    <property name="configLocation">
        <value>classpath:hibernate.cfg.xml</value>
    </property>
    <property name="configurationClass">
        <value>org.hibernate.cfg.AnnotationConfiguration</value>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${mysql.dialect}</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.connection.useUnicode">true</prop>
            <prop key="hibernate.connection.characterEncoding">UTF-8</prop>
            <prop key="hibernate.connection.charSet">UTF-8</prop>
            <prop key="hibernate.connection.url">${dwh.db.url}</prop>
            <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
         </props>
    </property>
</bean>

【问题讨论】:

    标签: java mysql hibernate group-by


    【解决方案1】:

    我认为您可以在 JDBC 连接字符串中设置sql_mode,例如

    jdbc:mysql://localhost:3306/dbName?sessionVariables=sql_mode=''
    

    【讨论】:

    • 适用于 MySQL v 5.17。谢谢!
    【解决方案2】:

    对于 mysql 8.0

    jdbc:mysql://localhost:3306/dbName?sessionVariables=&&sql-mode=''
    

    【讨论】:

    • 为什么要加倍&amp;&amp;
    猜你喜欢
    • 2017-03-30
    • 2014-07-18
    • 2011-10-13
    • 1970-01-01
    • 2018-05-10
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    相关资源
    最近更新 更多