spring orm hibernate 5.0 NamingStrategy

ddatsh 发布于 2015/08/21 18:17
阅读 2K+
收藏 0
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
        <property name="packagesToScan" value="com.xx"/>
        <property name="jpaProperties">
            <props>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
            	<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                <!-- 命名规则 My_NAME->myName -->
                <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
            </props>
        </property>
    </bean>

之前DB字段是下划线,用ImprovedNamingStrategy即可,hibernate 5.0,spring 4.2.0 后

org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(129) | Unknown column 'xx.fieldName' in 'field list'

变成驼峰了



加载中
返回顶部
顶部