Skip to content

Commit

Permalink
quarkusio#34443 Quarkus 3 native image fail to start with NoSuchMetho…
Browse files Browse the repository at this point in the history
…d Exception
  • Loading branch information
humcqc committed Jun 30, 2023
1 parent 7029323 commit 661223c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private static DotName createConstant(String fqcn) {
public static final DotName STATEMENT_INSPECTOR = createConstant("org.hibernate.resource.jdbc.spi.StatementInspector");

public static final List<DotName> GENERATORS = List.of(
createConstant("org.hibernate.generator.internal.TenantIdGeneration"),
createConstant("org.hibernate.generator.internal.CurrentTimestampGeneration"),
createConstant("org.hibernate.generator.internal.GeneratedAlwaysGeneration"),
createConstant("org.hibernate.generator.internal.GeneratedGeneration"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.it.jpa.generatedvalue;

import jakarta.enterprise.context.RequestScoped;

import io.quarkus.hibernate.orm.PersistenceUnitExtension;
import io.quarkus.hibernate.orm.runtime.tenant.TenantResolver;

@PersistenceUnitExtension
@RequestScoped
public class CustomTenantResolver implements TenantResolver {

private static final String DEFAULT_TENANT = "default";

@Override
public String getDefaultTenantId() {
return DEFAULT_TENANT;
}

@Override
public String resolveTenantId() {
return DEFAULT_TENANT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.hibernate.annotations.CurrentTimestamp;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GeneratedColumn;
import org.hibernate.annotations.TenantId;
import org.hibernate.annotations.UpdateTimestamp;

@Entity
Expand All @@ -19,6 +20,9 @@ public class EntityWithGeneratedValues {
@GeneratedValue
public Integer id;

@TenantId
public String tenant;

@CreationTimestamp
public Instant creationTimestamp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public String test() throws Exception {
var entity = new EntityWithGeneratedValues();
assertThat(entity).satisfies(
e -> assertThat(e.id).isNull(),
e -> assertThat(e.tenant).isNull(),
e -> assertThat(e.creationTimestamp).isNull(),
e -> assertThat(e.updateTimestamp).isNull(),
e -> assertThat(e.currentTimestamp).isNull(),
Expand All @@ -35,6 +36,7 @@ public String test() throws Exception {
em.flush();
assertThat(entity).satisfies(
e -> assertThat(e.id).isNotNull(),
e -> assertThat(e.tenant).isNotNull(),
e -> assertThat(e.creationTimestamp).isNotNull(),
e -> assertThat(e.updateTimestamp).isNotNull(),
e -> assertThat(e.currentTimestamp).isNotNull(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test
quarkus.hibernate-orm.database.generation=drop-and-create

quarkus.hibernate-orm.metadata-builder-contributor=io.quarkus.it.jpa.defaultcatalogandschema.Schema1MetadataBuilderContributor

quarkus.hibernate-orm.multitenant=DISCRIMINATOR

0 comments on commit 661223c

Please sign in to comment.