为了账号安全,请及时绑定邮箱和手机立即绑定

我JPA配置多数据库源后,驼峰写法的字段无法映射到 下划线的数据库字段, 也无法打印sql参数

我JPA配置多数据库源后,驼峰写法的字段无法映射到 下划线的数据库字段, 也无法打印sql参数

weixin_慕数据1513485 2019-11-28 16:45:30
package com.example.msmultipledatasource.configuration; import com.zaxxer.hikari.HikariDataSource; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.Database; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.sql.DataSource; import java.util.Properties; @Configuration @EnableJpaRepositories(         basePackages = {"com.example.msmultipledatasource.dao.first"},// 1. dao 层所在的包         entityManagerFactoryRef = "firstEntityManagerFactory") @EnableTransactionManagement public class FirstDataSourceConfigure {     @Bean     @Primary     public LocalContainerEntityManagerFactoryBean firstEntityManagerFactory() {         LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();         factoryBean.setDataSource(firstDataSource());         HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();         jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.SQLServer2008Dialect");         jpaVendorAdapter.setDatabase(Database.SQL_SERVER);         jpaVendorAdapter.setShowSql(true);         factoryBean.setJpaVendorAdapter(jpaVendorAdapter);         // 2. 实体类所在的包         factoryBean.setPackagesToScan("com.example.msmultipledatasource.domain.first");         return factoryBean;     }     @Bean     @Primary     @ConfigurationProperties("app.datasource.first")     public DataSourceProperties firstDataSourceProperties() {         return new DataSourceProperties();     }     @Bean     @Primary     @ConfigurationProperties("app.datasource.first.configuration")     public DataSource firstDataSource() {         return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();     } }logging:   level:      org.hibernate.type.descriptor.sql.BasicBinder: trace spring:   application:     name: msmultipledatasource   jpa:     show-sql: true     hibernate:       naming:         physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy         implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy eureka:   client:     service-url:       defaultZone: http://127.0.0.1:8761/eureka/ app:     datasource:       first:         driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver         url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ckgl         username: sa         password:        second:         driver-class-name: com.mysql.jdbc.Driver         url: jdbc:mysql://127.0.0.1:3306/springcloud_sell?characterEncoding=utf-8&useSSL=false         username: root         password: 123456
查看完整描述

1 回答

?
weixin_慕数据1513485

TA贡献1条经验 获得超0个赞

是SQL server分页的SQL才没有打印参数,其他打印参数是正常的。

查看完整回答
反对 回复 2019-11-28
  • 1 回答
  • 0 关注
  • 1932 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信