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

Remove support for hibernate.properties (long deprecated) #17538

Merged
merged 2 commits into from
Jun 2, 2021

Conversation

Sanne
Copy link
Member

@Sanne Sanne commented May 29, 2021

#Fixes #17537

@gsmet gsmet requested a review from yrodiere May 31, 2021 16:47
@gsmet
Copy link
Member

gsmet commented May 31, 2021

@Sanne could you have a look at George's comment?

Copy link
Member

@yrodiere yrodiere left a comment

Choose a reason for hiding this comment

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

I'll copy my comment from the issue:

but it appears from report #17515 that this was no longer working at all.

The question is how long has this not been working. At least on April 13th, it was still working, since there's a reproducer here that uses hibernate.properties as a workaround: #16463

After some investigation, my use of hibernate.properties in #16463 apparently didn't work. I don't know why I thought it did.

Anyway... It led me to investigate a bit more. I believe hibernate.properties does work in very few cases. Hibernate ORM discovers the hibernate.properties by itself, at runtime, in org.hibernate.cfg.Environment, and these properties are used in a few places.

In particular:

  • In org.hibernate.dialect.MySQLDialect#MySQLDialect to determine the storage engine.
  • In a few global settings that are deprecated, but still used:
    • org.hibernate.cfg.Environment#ENABLE_BINARY_STREAMS
      • Controls the value of org.hibernate.internal.FastSessionServices#useStreamForLobBinding
    • org.hibernate.cfg.Environment#ENABLE_REFLECTION_OPTIMIZER
      • Controls the use of reflection optimizers in org.hibernate.tuple.entity.PojoEntityTuplizer and org.hibernate.tuple.component.PojoComponentTuplizer.
    • org.hibernate.cfg.Environment#ENABLE_LEGACY_PROXY_CLASSNAMES
      • Controls the value of org.hibernate.bytecode.internal.bytebuddy.BasicProxyFactoryImpl#PROXY_NAMING_SUFFIX and org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper#PROXY_NAMING_SUFFIX
  • In org.hibernate.cfg.Environment#BYTECODE_PROVIDER_INSTANCE, which is used:
    • When deserializing proxies: org.hibernate.proxy.pojo.bytebuddy.SerializableProxy#readResolve
    • In Ant/Maven/Gradle plugins: org.hibernate.tool.enhance.EnhancementTask#execute/org.hibernate.orm.tooling.maven.MavenEnhancePlugin#execute/org.hibernate.orm.tooling.gradle.EnhancementHelper#enhance
  • Some other places that are not relevant to Quarkus, as far as I can see.

So I don't know how I should feel about this patch. Yes it removes dead code, but it doesn't completely remove support for hibernate.properties, which will still work... sometimes.

If we really want to close this topic for good, I'd suggest maybe adding some code to log a warning on startup if there is a hibernate.properties, and remove the file entirely? That way, we're sure there won't be any confusion as to whether it works or not.

@Sanne Sanne force-pushed the NoMoreHibernateProperties branch from 13930ae to 2a8d56d Compare June 1, 2021 09:10
@Sanne
Copy link
Member Author

Sanne commented Jun 1, 2021

updated the commit

@Sanne
Copy link
Member Author

Sanne commented Jun 1, 2021

hi @yrodiere , thanks for the analysis! And sorry I've only seen your comment after pushing the rebased version.

So I don't know how I should feel about this patch. Yes it removes dead code, but it doesn't completely remove support for hibernate.properties, which will still work... sometimes.

If we really want to close this topic for good, I'd suggest maybe adding some code to log a warning on startup if there is a hibernate.properties, and remove the file entirely? That way, we're sure there won't be any confusion as to whether it works or not.

Regarding having the warning, you mean like the warning we had in QuarkusEnvironment ? (the very few lines this PR is removing?)

Regarding "and remove the file entirely?" , WDYM - to remove the hibernate.properties file from the project? I don't think we should try to remove source files.

@yrodiere
Copy link
Member

yrodiere commented Jun 1, 2021

Regarding having the warning, you mean like the warning we had in QuarkusEnvironment ? (the very few lines this PR is removing?)

I mean that a user including a hibernate.properties in his project should get a warning during the build, because that hibernate.properties will be ignored and that's very much non-standard behavior. Principle of least surprise and whatnot.

Regarding "and remove the file entirely?" , WDYM - to remove the hibernate.properties file from the project? I don't think we should try to remove source files.

I meant not adding it to the JAR. I agree we shouldn't alter source files.

@Sanne
Copy link
Member Author

Sanne commented Jun 1, 2021

I meant not adding it to the JAR. I agree we shouldn't alter source files.

I don't think we have the ability to override what the build tool will do?

Regarding the warning, yes good idea. So you mean similar to the warning we had until now, but processed by the deployment component, right?

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM

@yrodiere
Copy link
Member

yrodiere commented Jun 1, 2021

I meant not adding it to the JAR. I agree we shouldn't alter source files.

I don't think we have the ability to override what the build tool will do?

Too bad. I thought, since we can add class files, why not remove resource files... But ok. The warning should address the problem for the vast majority of users.

Regarding the warning, yes good idea. So you mean similar to the warning we had until now, but processed by the deployment component, right?

Yes.

@Sanne Sanne force-pushed the NoMoreHibernateProperties branch from 2a8d56d to 6f44b40 Compare June 1, 2021 19:27
@Sanne
Copy link
Member Author

Sanne commented Jun 1, 2021

@yrodiere adapted and rebased. I went a step further and decided to throw an exception rather than logging a warning - I know it's rather aggressive, but I prefer motivating feedback on this with more urgency than what I'd get with a warning.

@yrodiere
Copy link
Member

yrodiere commented Jun 2, 2021

I went a step further and decided to throw an exception rather than logging a warning

I'm not sure that's wise, as there are some people out there who pull legacy JARs, which contain a persistence.xml. It's not that much of a stretch to assume that other people pull legacy JARs that contain a hibernate.properties, and they can't change that.

Anyway, +1 to merge as long as everyone is okay with breaking existing applications that contain a hibernate.properties. I think @gsmet might want to know about this before we merge.

@Sanne
Copy link
Member Author

Sanne commented Jun 2, 2021

. It's not that much of a stretch to assume that other people pull legacy JARs that contain a hibernate.properties, and they can't change that.

Right, that's why I have the error message print the location.

Regarding this being problematic for legacy applications, I agree with your concern but still think we need to hear about those and you also pointed out yourself how problematic that can be - and Quarkus has always made it clear it's not meant for legacy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove (deprecated) support for hibernate.properties
4 participants