I\'m trying to use JPA @Embeddables with Hibernate. The entity and the embeddable both have a property named id:
@MappedSuperclass
The naming strategy configuration has changed. The new way as per the Spring Boot documentation is this:
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
Also, you must not use @Id within an @Embeddable. I thus created a seperate @MappedSuperclass for embeddables:
@MappedSuperclass
public abstract class A {
@Id
@GeneratedValue
long id;
}
@MappedSuperclass
public abstract class E {
@GeneratedValue
long id;
}
@Embeddable
public class B extends E {
}
@Entity
public class C extends A {
B b;
}
This way, the table C has two columns id and b_id. The downside is of course that A and E introduce some redundency. Comments regarding a DRY approach to this are very welcome.