In my primary Entity I have two instances of an embeddable type like this:
@Embeddable
public class VariableDate {
protected Instant value;
protected CustomEnum type;
}
@Entity
public class MyEntity {
protected VariableDate begin;
protected VariableDate end;
}
This yields the following exception:
Caused by: org.hibernate.MappingException:
Repeated column in mapping for entity: de.company.MyEntity column: value
(should be mapped with insert="false" update="false")
According to this SO response I need to specify the naming strategy:
org.hibernate.cfg.DefaultComponentSafeNamingStrategy
I tried specifying the naming strategy in my application.properties
according to the 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 all combinations (both at the same time, each individually and none), unfortunately I receive above mentioned exception in any case.
The remaining database configuration from application.properties
:
spring.datasource.url=jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=user
# password provided by 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 are 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 would be storing the values in columns like begin_value
, begin_type
, end_value
, end_type
in the table for MyEntity
.
Edit: The correct solution was posted here already: https://stackoverflow.com/a/43412964/3388491