-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpannerSchemaManagementTool singleton prevents having multiple persistence units #406
Comments
On a first glance, this basic sample works fine with multiple entities. @olavloite do you have any context on this by any chance? |
This sample is not relevant, because the problem is not about having multiple entities. The problem is about having multiple persistence units, i.e. multiple instances of Hibernate ORM in the same application. In that case, you have multiple service registries and multiple entity manager factories. If your If you need a reproducer beyond the one from quarkusio/quarkus#24742, you only need to set up an application with two persistence units, each with different entities, and each pointing to a different Google Spanner instance, with database schema generation enabled in Hibernate ORM (that should be the default).
|
Thank you for the detailed explanation. We will look into this. |
@yrodiere we welcome contributions for this from the community. |
@meltsufin Then let's hope the community will provide a contribution. I'm not personally a Spanner user, so fixing bugs in this project unfortunately cannot be a priority for me, but I'll see if I have time to have a look in the future. |
Thanks for providing the initial context for this issue! We will keep this issue open as we await contributions from the community. |
See here:
google-cloud-spanner-hibernate/google-cloud-spanner-hibernate-dialect/src/main/java/com/google/cloud/spanner/hibernate/SpannerServiceContributor.java
Lines 42 to 45 in 2c97da0
SpannerSchemaManagementTool
is effectively a singleton, but it gets injected with information specific to the persistence unit. If it's reused across multiple persistence unit, it will only keep information about the last persistence unit to start, and schema management for the previous persistence units will not work correctly.You can find more information on the kind of problems this leads to here: quarkusio/quarkus#24742
In order to solve this problem,
SpannerServiceContributor
should create one instance ofSpannerSchemaManagementTool
each time the service is initiated. That's whatorg.hibernate.tool.schema.internal.SchemaManagementToolInitiator
, the default implementation, does.The text was updated successfully, but these errors were encountered: