Skip to content
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

Multiple persistence units follow up #11519

Merged
merged 5 commits into from Aug 26, 2020

Conversation

gsmet
Copy link
Member

@gsmet gsmet commented Aug 21, 2020

@Sanne these are some small changes we talked about.

The Hibernate Validator is related to yesterday's PR: this way we won't miss bootstrap error anymore. Didn't include it in yesterday's PR because it would have conflicted with the Multi persistence units one.

@boring-cyborg boring-cyborg bot added the area/hibernate-orm Hibernate ORM label Aug 21, 2020
if (capabilities.isMissing(Capability.TRANSACTIONS)) {
// JTA is necessary for blocking Hibernate ORM but not necessarily for Hibernate Reactive
if (capabilities.isMissing(Capability.TRANSACTIONS)
&& capabilities.isMissing(Capability.HIBERNATE_REACTIVE)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -575,7 +577,9 @@ private void handleHibernateORMWithNoPersistenceXml(
jdbcDataSources, applicationArchivesBuildItem, launchMode,
systemProperties, nativeImageResources, hotDeploymentWatchedFiles, persistenceUnitDescriptors);

storageEngines.add(persistenceUnitEntry.getValue().dialect.storageEngine);
if (persistenceUnitEntry.getValue().dialect.storageEngine.isPresent()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a corner case which might have a surprise effect to users:

  1. DB-1 using MySQL (or MariaDB) and sets a weird engine like BLACKHOLE
  2. DB-2 using MySQL (or MariaDB) and doesn't set anything
  3. all data written on DB-2 disappears as well without warning ?

IMO we need to require full consistency among the MySQL/MariaDB configured PUs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the issue is that we have no way to detect this properly. We could assert the db-kind but people can do whatever they want with that.

We could catch 99% of the mistakes though, probably better than what I did.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultimately the engine variable is read by the MySQL Dialect. So we know it's going to affect people either if they choose any of the extensions ofthe MySQLDialect (explicitly), or if we'll be chosing such a dialect based on the db-kind .. isn't that 100% ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. Frankly, I think that's a lot of work for something that is half baked in ORM :/. This should never has been included in ORM that way. I'll see what I can do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it's half baked and I suppose there's better use of your time. Feel free to postpone it into a different issue?

// if there is any issue when bootstrapping Hibernate Validator.
if (capabilities.isPresent(Capability.HIBERNATE_VALIDATOR)) {
descriptor.getProperties().setProperty(AvailableSettings.JPA_VALIDATION_MODE, ValidationMode.CALLBACK.name());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -17,7 +17,8 @@
.setExpectedException(ConfigurationException.class)
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(User.class)
.addAsResource("application-multiple-persistence-units-invalid.properties", "application.properties"));
.addAsResource("application-multiple-persistence-units-undefined-packages.properties",
"application.properties"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@Sanne Sanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I forgot to explicitly marking this as approved. @gsmet not sure if you were planning to make any more changes so I'll leave it to you to press the merge button..

@gsmet gsmet force-pushed the multi-persistence-units-follow-up branch from 3e9a8a8 to 50ee306 Compare August 26, 2020 09:41
@gsmet
Copy link
Member Author

gsmet commented Aug 26, 2020

@Sanne I added a commit along the lines of what we discussed for the storage engines. The MySQL/MariaDB test is a bit naive but I think it will do. We can refine later if someone complains.

The storage engine is only used by MySQL/MariaDB so a setup with a MySQL
PU using a storage engine and a PostgreSQL PU not using any is perfectly
valid.
With auto, if we have an error when bootstrapping the Bean Validation
integration, the error will be swallowed and all validation will be
ignored. It's far better to report an error in this case.
/**
* This is just to have the dialect matching MySQL and trigger the MySQL + storage engines check.
*/
public static class H2DialectWithMySQLInTheName extends H2Dialect {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funny :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I didn't want to end up with MySQL there :).

@Sanne
Copy link
Member

Sanne commented Aug 26, 2020

thanks @gsmet ! It's not bullet-proof but I always merge progress ;)

@Sanne Sanne added this to the 1.8.0 - master milestone Aug 26, 2020
@Sanne Sanne added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 26, 2020
@gsmet
Copy link
Member Author

gsmet commented Aug 26, 2020

Yeah I agree, it's not perfect but better than nothing :).

@gsmet gsmet merged commit dcf945f into quarkusio:master Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants