我的数据库列与user_id类似,但实体是userId。我不想@column注释。我想使用命名的stratrgy来配置它。
在application.xml和persistence.xml上配置如下:
application.xml中
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="persistenceForCCP" />
<property name="persistenceXmlLocation" value="classpath*:/persistenceForCCP.xml" />
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
<property name="jpaDialect" ref="jpaDialect" />
<property name="dataSource" ref="dataSourceForCCP" />
<property name="jpaProperties">
<props>
<!-- <prop key="spring.jpa.hibernate.naming.implicit.strategy">org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl</prop> -->
<prop key=" hibernate.physical_naming_strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<!-- <prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop> -->
</props>
</property>
</bean>
persistence.xml like below
<property name="hibernate.physical_naming_strategy" value="org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="hibernate.current_session_context_class" value="jta"/>
<property name="hibernate.connection.release_mode" value="after_statement"/>
但是如下所示的消息
休眠:
select
couriercom0_.id as id1_0_,
couriercom0_.billNoProvider as billNoPr2_0_,
couriercom0_.createDateGMT as createDa3_0_,
couriercom0_.createDateLoc as createDa4_0_,
couriercom0_.createDateLocTz as createDa5_0_,
couriercom0_.isActive as isActive6_0_,
couriercom0_.name as name7_0_,
couriercom0_.timestamp as timestam8_0_
from
courier_company couriercom0_
2017-11-24 15:05:51 860 WARN SqlExceptionHelper:129 [:] - SQL错误: 1054,SQLState:42S22