{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15318","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15318/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15318/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15318/events","html_url":"https://github.com/spring-projects/spring-boot/issues/15318","id":385225774,"node_id":"MDU6SXNzdWUzODUyMjU3NzQ=","number":15318,"title":"Make it easier to use the auto-configured EntityManagerFactoryBuilder with Hibernate-specific properties","user":{"login":"petenattress","id":7677823,"node_id":"MDQ6VXNlcjc2Nzc4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/7677823?v=4","gravatar_id":"","url":"https://api.github.com/users/petenattress","html_url":"https://github.com/petenattress","followers_url":"https://api.github.com/users/petenattress/followers","following_url":"https://api.github.com/users/petenattress/following{/other_user}","gists_url":"https://api.github.com/users/petenattress/gists{/gist_id}","starred_url":"https://api.github.com/users/petenattress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petenattress/subscriptions","organizations_url":"https://api.github.com/users/petenattress/orgs","repos_url":"https://api.github.com/users/petenattress/repos","events_url":"https://api.github.com/users/petenattress/events{/privacy}","received_events_url":"https://api.github.com/users/petenattress/received_events","type":"User","site_admin":false},"labels":[{"id":1130210432,"node_id":"MDU6TGFiZWwxMTMwMjEwNDMy","url":"https://api.github.com/repos/spring-projects/spring-boot/labels/for:%20team-meeting","name":"for: team-meeting","color":"c5def5","default":false},{"id":16916893,"node_id":"MDU6TGFiZWwxNjkxNjg5Mw==","url":"https://api.github.com/repos/spring-projects/spring-boot/labels/type:%20enhancement","name":"type: enhancement","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/126","html_url":"https://github.com/spring-projects/spring-boot/milestone/126","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/126/labels","id":3785738,"node_id":"MDk6TWlsZXN0b25lMzc4NTczOA==","number":126,"title":"2.2.x","description":"","creator":{"login":"philwebb","id":519772,"node_id":"MDQ6VXNlcjUxOTc3Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/519772?v=4","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":0,"state":"open","created_at":"2018-10-31T14:47:26Z","updated_at":"2018-12-03T10:04:47Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-11-28T11:33:58Z","updated_at":"2018-12-03T10:21:35Z","closed_at":null,"author_association":"NONE","body":"This relates to #3654 - I was asked to open a new issue by @wilkinsona.\r\n\r\nWhen I followed the guidance in the Spring Boot documentation on [how to define two entity managers](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-two-entity-managers), the mappings for my original entity manager stopped working, with exceptions such as this:\r\n\r\n```\r\nCaused by: org.hibernate.MappingException: Unable to find column with logical name: some_id in some_table\r\n\tat org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:858) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]\r\n...\r\n```\r\n\r\nAs #3654 describes, this was due to the `EntityManagerFactoryBuilder` not containing the Spring `naming_strategy` properties which are populated by the auto-configuration when Boot creates the entity manager itself. This took me a while to get to the bottom of because the documentation does not point this out, in fact it kind of implies that the `EntityManagerFactoryBuilder` can be used to construct an entity manager in the same way the auto-configuration does.\r\n\r\nFor my use case, it would be useful if the `EntityManagerFactoryBuilder` contained the same set of properties created by the auto-configuration, especially to preserve the \"clever\" behaviour of the `ddl-auto` option being set differently for integration tests against an embedded database. As is, I am required to replicate this behaviour in my configuration class - I have done this for now by wiring in the properties that I could (this isn't identical to the auto-configuration, but it's close enough for my current needs):\r\n\r\n```java\r\n@Bean\r\npublic LocalContainerEntityManagerFactoryBean myEntityManagerFactory(EntityManagerFactoryBuilder builder,\r\n                                                                     DataSource dataSource,\r\n                                                                     JpaProperties jpaProperties,\r\n                                                                     HibernateProperties hibernateProperties) {\r\n  HibernateSettings hibernateSettings = new HibernateSettings();\r\n\r\n  return builder\r\n      .dataSource(dataSource)\r\n      .properties(hibernateProperties.determineHibernateProperties(jpaProperties.getProperties(), hibernateSettings))\r\n      .packages(SomePackage.class)\r\n      .persistenceUnit(\"someUnit\")\r\n      .build();\r\n}\r\n```\r\n\r\nI understand that other use cases may not find the auto-population of properties useful, and that making such a change is probably not backwards compatible. If the change is not possible, I think the documentation should be updated to clarify the behaviour and ideally demonstrate how to work around it like in my example above. Perhaps as a compromise, there could be a nicer way of wiring in the result of the call to `hibernateProperties.determineHibernateProperties`, which I think is all I need.\r\n\r\nMany thanks."},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/443659465","html_url":"https://github.com/spring-projects/spring-boot/issues/15318#issuecomment-443659465","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/15318","id":443659465,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzY1OTQ2NQ==","user":{"login":"petenattress","id":7677823,"node_id":"MDQ6VXNlcjc2Nzc4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/7677823?v=4","gravatar_id":"","url":"https://api.github.com/users/petenattress","html_url":"https://github.com/petenattress","followers_url":"https://api.github.com/users/petenattress/followers","following_url":"https://api.github.com/users/petenattress/following{/other_user}","gists_url":"https://api.github.com/users/petenattress/gists{/gist_id}","starred_url":"https://api.github.com/users/petenattress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petenattress/subscriptions","organizations_url":"https://api.github.com/users/petenattress/orgs","repos_url":"https://api.github.com/users/petenattress/repos","events_url":"https://api.github.com/users/petenattress/events{/privacy}","received_events_url":"https://api.github.com/users/petenattress/received_events","type":"User","site_admin":false},"created_at":"2018-12-03T10:21:35Z","updated_at":"2018-12-03T10:21:35Z","author_association":"NONE","body":"Many thanks @wilkinsona, that sounds good."}}
{"actor":{"display_login":"petenattress"}}