Skip to content

Commit

Permalink
"normalize" the package name on package rules lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Mar 26, 2024
1 parent 6974793 commit e94f9d5
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,8 @@ public static Map<String, Set<String>> getModelClassesAndPackagesPerPersistenceU
}

for (String modelPackageName : jpaModel.getAllModelPackageNames()) {
Set<String> persistenceUnitNames = packageRules.get(modelPackageName);
// Package rules keys are "normalized" package names, so we want to normalize the package on lookup:
Set<String> persistenceUnitNames = packageRules.get(normalizePackage(modelPackageName));
if (persistenceUnitNames == null) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import jakarta.persistence.Embeddable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

/**
* @author Emmanuel Bernard emmanuel@hibernate.org
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import java.time.LocalDate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import jakarta.persistence.MappedSuperclass;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import java.time.LocalDate;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import java.io.IOException;
import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

/**
* Should not be referenced by the code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import java.time.Duration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

public enum Status {
LIVING,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.it.jpa.postgresql;
package io.quarkus.it.jpa.postgresql.defaultpu;

import jakarta.persistence.Embeddable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;

import org.hibernate.annotations.Filter;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

Expand All @@ -15,6 +16,8 @@
import io.quarkus.runtime.annotations.RegisterForReflection;

@Entity
@Filter(name = "ids-over-zero")
@Filter(name = "ids-over-zero-inner-package")
public class EntityWithJsonOtherPU {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@FilterDef(name = "ids-over-zero-inner-package", defaultCondition = "id > 0")
package io.quarkus.it.jpa.postgresql.otherpu.inner;

import org.hibernate.annotations.FilterDef;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This filter is useless in terms of filtering, but we want to be sure that
* Quarkus detects and processes ORM annotations defined at a package level:
*/
@FilterDef(name = "ids-over-zero", defaultCondition = "id > 0")
package io.quarkus.it.jpa.postgresql.otherpu;

import org.hibernate.annotations.FilterDef;
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ quarkus.datasource.password=hibernate_orm_test
quarkus.datasource.jdbc.url=${postgres.url}
quarkus.datasource.jdbc.max-size=8

quarkus.hibernate-orm.packages=io.quarkus.it.jpa.postgresql
quarkus.hibernate-orm.packages=io.quarkus.it.jpa.postgresql.defaultpu
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.database.generation.create-schemas=true
# Define non-default PU so that we can configure a custom JSON format mapper. The default PU is using the default mapper.
quarkus.hibernate-orm."other".datasource=<default>
quarkus.hibernate-orm."other".packages=io.quarkus.it.jpa.postgresql.otherpu
quarkus.hibernate-orm."other".packages=io.quarkus.it.jpa.postgresql.otherpu,io.quarkus.it.jpa.postgresql.otherpu.inner
quarkus.hibernate-orm."other".database.generation=drop-and-create
quarkus.hibernate-orm."other".database.generation.create-schemas=true

#Necessary for assertions in JPAFunctionalityInGraalITCase:
quarkus.native.enable-reports=true

0 comments on commit e94f9d5

Please sign in to comment.