3

Essentially what I'm trying to do is to add this property change to hibernate so I can enable instantiation of composite/embeddable objects when all of its attribute values are null:

hibernate.create_empty_composites.enabled

I am aware that the usual way to edit Hibernate is in the application.properties file like so:

################################################################################
#                               JPA MANAGEMENT                                 #
################################################################################
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true...
...
spring.jpa.properties.hibernate.create_empty_composites.enabled=true

But the spring.jpa.properties.hibernate.create_empty_composites.enabled=true isn't working. I'm not sure if Spring just doesn't recognize certain properties or if it's just the wrong place to put it.

What I'd like to know is if there is another way to edit the Hibernate properties directly or if there is another fix.

DreamCloud
  • 113
  • 1
  • 9

1 Answers1

3

Analysis

The base assumption. More likely you are using Spring Boot 1.5.*.

  1. Spring Boot 1.5.* uses Hibernate 5.0.*. GitHub proof.

  2. Hibernate supports the hibernate.create_empty_composites.enabled setting since the 5.1 version.

Solution

Please consider upgrading the Hibernate dependency in your pom.xml to a more recent version (5.1 and higher).

After that, it should work just fine:

In addition all properties in spring.jpa.properties.* are passed through as normal JPA properties (with the prefix stripped) when the local EntityManagerFactory is created.

Spring Boot 1.5.* reference, 77. Data Access, 77.5 Configure JPA properties.