Skip to content

Commit

Permalink
Make QuarkusPersistenceUnitDescriptor available to FastBootHibernateP…
Browse files Browse the repository at this point in the history
…ersistenceProvider

Not strictly necessary, but doesn't hurt and might allow more changes in
the next commits.
  • Loading branch information
yrodiere committed Jun 21, 2024
1 parent a07509e commit dc732fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ private EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String
final Object validatorFactory = Arc.container().instance("quarkus-hibernate-validator-factory").get();

return new FastBootEntityManagerFactoryBuilder(
persistenceUnit,
metadata /* Uses the StandardServiceRegistry references by this! */,
persistenceUnitName,
standardServiceRegistry /* Mostly ignored! (yet needs to match) */,
runtimeSettings,
validatorFactory, cdiBeanManager, recordedState.getMultiTenancyStrategy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

public class FastBootEntityManagerFactoryBuilder implements EntityManagerFactoryBuilder {

protected final QuarkusPersistenceUnitDescriptor puDescriptor;
protected final PrevalidatedQuarkusMetadata metadata;
protected final String persistenceUnitName;
protected final StandardServiceRegistry standardServiceRegistry;
private final RuntimeSettings runtimeSettings;
private final Object validatorFactory;
Expand All @@ -56,11 +56,12 @@ public class FastBootEntityManagerFactoryBuilder implements EntityManagerFactory
protected final MultiTenancyStrategy multiTenancyStrategy;

public FastBootEntityManagerFactoryBuilder(
PrevalidatedQuarkusMetadata metadata, String persistenceUnitName,
QuarkusPersistenceUnitDescriptor puDescriptor,
PrevalidatedQuarkusMetadata metadata,
StandardServiceRegistry standardServiceRegistry, RuntimeSettings runtimeSettings, Object validatorFactory,
Object cdiBeanManager, MultiTenancyStrategy multiTenancyStrategy) {
this.puDescriptor = puDescriptor;
this.metadata = metadata;
this.persistenceUnitName = persistenceUnitName;
this.standardServiceRegistry = standardServiceRegistry;
this.runtimeSettings = runtimeSettings;
this.validatorFactory = validatorFactory;
Expand All @@ -82,7 +83,7 @@ public EntityManagerFactoryBuilder withDataSource(DataSource dataSource) {
public EntityManagerFactory build() {
try {
final SessionFactoryOptionsBuilder optionsBuilder = metadata.buildSessionFactoryOptionsBuilder();
populate(persistenceUnitName, optionsBuilder, standardServiceRegistry);
populate(puDescriptor.getName(), optionsBuilder, standardServiceRegistry);
return new SessionFactoryImpl(metadata, optionsBuilder.buildOptions(),
metadata.getTypeConfiguration().getMetadataBuildingContext().getBootstrapContext());
} catch (Exception e) {
Expand Down Expand Up @@ -130,7 +131,7 @@ protected PersistenceException persistenceException(String message, Exception ca
}

private String getExceptionHeader() {
return "[PersistenceUnit: " + persistenceUnitName + "] ";
return "[PersistenceUnit: " + puDescriptor.getName() + "] ";
}

protected void populate(String persistenceUnitName, SessionFactoryOptionsBuilder options, StandardServiceRegistry ssr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ private EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String
final Object validatorFactory = Arc.container().instance("quarkus-hibernate-validator-factory").get();

return new FastBootReactiveEntityManagerFactoryBuilder(
persistenceUnit,
metadata /* Uses the StandardServiceRegistry references by this! */,
persistenceUnitName,
standardServiceRegistry /* Mostly ignored! (yet needs to match) */,
runtimeSettings,
validatorFactory, cdiBeanManager, recordedState.getMultiTenancyStrategy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
import io.quarkus.hibernate.orm.runtime.RuntimeSettings;
import io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder;
import io.quarkus.hibernate.orm.runtime.boot.QuarkusPersistenceUnitDescriptor;
import io.quarkus.hibernate.orm.runtime.migration.MultiTenancyStrategy;
import io.quarkus.hibernate.orm.runtime.recording.PrevalidatedQuarkusMetadata;

public final class FastBootReactiveEntityManagerFactoryBuilder extends FastBootEntityManagerFactoryBuilder {

public FastBootReactiveEntityManagerFactoryBuilder(PrevalidatedQuarkusMetadata metadata, String persistenceUnitName,
public FastBootReactiveEntityManagerFactoryBuilder(QuarkusPersistenceUnitDescriptor puDescriptor,
PrevalidatedQuarkusMetadata metadata,
StandardServiceRegistry standardServiceRegistry, RuntimeSettings runtimeSettings, Object validatorFactory,
Object cdiBeanManager, MultiTenancyStrategy strategy) {
super(metadata, persistenceUnitName, standardServiceRegistry, runtimeSettings, validatorFactory,
super(puDescriptor, metadata, standardServiceRegistry, runtimeSettings, validatorFactory,
cdiBeanManager, strategy);
}

Expand Down

0 comments on commit dc732fd

Please sign in to comment.