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

Generate entities in correct class loader #7831

Merged
merged 1 commit into from
Mar 13, 2020

Conversation

stuartwdouglas
Copy link
Member

Fixes #7433

@boring-cyborg boring-cyborg bot added the area/hibernate-orm Hibernate ORM label Mar 12, 2020
@@ -760,7 +760,7 @@ private void enhanceEntities(final JpaEntitiesBuildItem domainObjects,
try {
byte[] bytes = IoUtil.readClassAsBytes(HibernateOrmProcessor.class.getClassLoader(), className);
byte[] enhanced = hibernateEntityEnhancer.enhance(className, bytes);
additionalClasses.produce(new GeneratedClassBuildItem(true, className, enhanced != null ? enhanced : bytes));
additionalClasses.produce(new GeneratedClassBuildItem(false, className, enhanced != null ? enhanced : bytes));
Copy link
Member

Choose a reason for hiding this comment

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

We are enhancing application classes and I don't understand why the enhanced classes should not be considered application classes?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are AdditionalJpaModelBuildItem classes, that are for entities defined in extensions. If we generate them in the application class loader then you end up with two copies, one in the runtime class loader and the original unmodified one in the base runtime class loader. Normally this is ok, unless a class in the base runtime CL attempts to use the entity, in which case you get problems.

@gsmet gsmet merged commit e90c41f into quarkusio:master Mar 13, 2020
@gsmet gsmet added this to the 1.3.0.Final milestone Mar 13, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

With AdditionalJpaModelBuildItem created Entity not working in dev mode
2 participants