java - How to configure SafeNamingStrategy for Spring Data JPA with Spring Boot -


in primary entity have 2 instances of embeddable type this:

@embeddable public class variabledate {     protected instant value;     protected customenum type; }  @entity public class myentity {     protected variabledate begin;     protected variabledate end; } 

this yields following exception:

caused by: org.hibernate.mappingexception:      repeated column in mapping entity: de.company.myentity column: value      (should mapped insert="false" update="false") 

according this response need specify naming strategy:

org.hibernate.cfg.defaultcomponentsafenamingstrategy 

i tried specifying naming strategy in application.properties according spring boot documentation:

spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.cfg.defaultcomponentsafenamingstrategy spring.jpa.hibernate.naming.physical-strategy=org.hibernate.cfg.defaultcomponentsafenamingstrategy 

i tested combinations (both @ same time, each individually , none), unfortunately receive above mentioned exception in case.

the remaining database configuration application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/database?useunicode=true&characterencoding=utf-8 spring.datasource.username=user # password provided external configuration # spring.datasource.password=password spring.datasource.testwhileidle=true spring.datasource.validationquery=select 1 spring.jpa.show-sql=false # hibernate ddl auto (create, create-drop, update, validate) spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.mysql5dialect 

the dependencies based on spring boot 1.5.2:

<parent>     <groupid>org.springframework.boot</groupid>     <artifactid>spring-boot-starter-parent</artifactid>     <version>1.5.2.release</version> </parent> 

a valid outcome storing values in columns begin_value, begin_type, end_value, end_type in table myentity.

edit: correct solution posted here already: https://stackoverflow.com/a/43412964/3388491


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -