Oleksii Miroshnyk (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a157d9...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYzgzZjQzMmQz...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-16734?atlOrigin=eyJpIjoiYzgzZj...
) HHH-16734 (
https://hibernate.atlassian.net/browse/HHH-16734?atlOrigin=eyJpIjoiYzgzZj...
) Add filtration by package name for enhancer (
https://hibernate.atlassian.net/browse/HHH-16734?atlOrigin=eyJpIjoiYzgzZj...
)
Issue Type: Improvement Affects Versions: 6.2.3 Assignee: Unassigned Components:
bytecode-enhancement Created: 01/Jun/2023 03:03 AM Priority: Major Reporter: Oleksii
Miroshnyk (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a157d9...
)
Seems in hibernate 6.2 bytecode enhancement is enabled by default
in
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl#EntityManagerFactoryBuilderImpl
propertyValue = configurationValues.remove(
AvailableSettings.ENHANCER_ENABLE_LAZY_INITIALIZATION );
if ( propertyValue != null ) {
lazyInitializationEnabled = Boolean.parseBoolean( propertyValue.toString() );
}
else {
lazyInitializationEnabled = true;
}
and the it does
if ( dirtyTrackingEnabled || lazyInitializationEnabled || associationManagementEnabled
) {
EnhancementContext enhancementContext = getEnhancementContext(
dirtyTrackingEnabled,
lazyInitializationEnabled,
associationManagementEnabled
);
persistenceUnit.pushClassTransformer( enhancementContext );
}
Probably it does some some good job, but it also starts to produce unexpected exceptions
about classes that you don’t use or even know. For example I’m facing some exception
OAuth2 security classes from spring while I’m not using spring outh2 security but it has
some imports to something else that is actually a root cause.
It is because there is no filtration by class name/package name and it tries to load any
class to check if it is entity, interface or not. And this can result that loader can go
through the imports and find some imports of classes that are not in the classpath.
I think introducing some file name/package name regex filtration prior loading/processing
class will help to mitigate those issues. Just class will be skipped by
transformer/enhancer it the very beginning.
Also probably it is a good idea to pre-populate it with well known packages - spring,
hibernate, ehcache etc
(
https://hibernate.atlassian.net/browse/HHH-16734#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16734#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:40c4da4 )