该应用程序是使用JHipster / Spring Boot和PostgreSQL构建的。基于this article,我有一个自定义UserType类和一个SQL方言类,如下所示
public class CustomPostgreSQLDialect extends PostgreSQL94Dialect {
public CustomPostgreSQLDialect() {
this.registerColumnType(Types.JAVA_OBJECT, "jsonb");
}
}
我在application.xml文件中将其配置为
spring:
...
jpa:
open-in-view: false
hibernate:
ddl-auto: none
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
properties:
hibernate.dialect: com.abc.customdatatypes.usertype.CustomPostgreSQLDialect
对于集成测试,
@Test
@Transactional
public void createProduct() throws Exception {
int databaseSizeBeforeCreate = productRepository.findAll().size();
// Create the Product
restProductMockMvc.perform(post("/api/products")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(product)))
.andExpect(status().isCreated());
// Validate the Product in the database
List<Product> productList = productRepository.findAll();
assertThat(productList).hasSize(databaseSizeBeforeCreate + 1);
Product testProduct = productList.get(productList.size() - 1);
assertThat(testProduct.getBrand()).isEqualTo(DEFAULT_BRAND);
assertThat(testProduct.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testProduct.getKeywords()).isEqualTo(DEFAULT_KEYWORDS);
assertThat(testProduct.getSpecs()).isEqualTo(DEFAULT_SPECS);
assertThat(testProduct.getSeason()).isEqualTo(DEFAULT_SEASON);
// Validate the Product in Elasticsearch
verify(mockProductSearchRepository, times(1)).save(testProduct);
}
我收到以下错误:
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: 2000
at org.hibernate.dialect.TypeNames.get(TypeNames.java:70)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:101)
at org.hibernate.dialect.Dialect.getTypeName(Dialect.java:346)
at org.hibernate.mapping.Column.getSqlType(Column.java:231)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateColumnType(AbstractSchemaValidator.java:156)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:143)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:312)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:460)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390)
... 68 more
似乎SQL方言配置无效。我将相同的配置行添加到application-dev.yml以及application-prod.xml,但没有运气。
是否可以找出SQL方言配置是否有效?