简体   繁体   中英

Disable ONLY_FULL_GROUP_BY in hibernate

I need to disable ONLY_FULL_GROUP_BY in hibernate. This is my current session factory. I am not sure how to specify the sql_mode='' in this.

<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>

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

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

对于 mysql 8.0

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

in local use: SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM