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

HHH-19004 Reproducer: TenantId regression on @EmbeddedId 6.6.0 -> 6.6.1 #464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion orm/hibernate-orm-6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<properties>
<version.com.h2database>2.3.232</version.com.h2database>
<version.junit-jupiter>5.11.4</version.junit-jupiter>
<version.org.hibernate.orm>6.6.4.Final</version.org.hibernate.orm>
<version.org.hibernate.orm>6.6.1.Final</version.org.hibernate.orm>
<version.org.assertj.assertj-core>3.27.1</version.org.assertj.assertj-core>
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package org.hibernate.bugs;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Table;
import java.io.Serializable;
import java.util.Map;
import org.hibernate.annotations.TenantId;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -25,6 +36,37 @@ void destroy() {
entityManagerFactory.close();
}

@Entity
@Table(name = "display_id")
public class DisplayIdBE {

@EmbeddedId
private DisplayIdKeyBE id;

@Column(name = "display_id_value", nullable = false)
private long displayIdValue;
}

public enum DisplayIdType {
TYPE1,
TYPE2
}

@Embeddable
public class DisplayIdKeyBE implements Serializable {

@TenantId
@Column(name = "tenant_id", nullable = false)
private Long tenantId;

@Column(name = "type", nullable = false)
@Enumerated(EnumType.STRING)
private DisplayIdType type;

// For Hibernate
protected DisplayIdKeyBE() {}
}

// Entities are auto-discovered, so just add them anywhere on class-path
// Add your tests, using standard JUnit.
@Test
Expand Down

This file was deleted.

14 changes: 14 additions & 0 deletions orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Resolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.hibernate.bugs;

import org.hibernate.context.spi.CurrentTenantIdentifierResolver;

public class Resolver implements CurrentTenantIdentifierResolver<Long> {
@Override
public Long resolveCurrentTenantIdentifier() {
return 0L;
}
@Override
public boolean validateExistingCurrentSessions() {
return false;
}
}
3 changes: 2 additions & 1 deletion orm/hibernate-orm-6/src/test/resources/hibernate.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ hibernate.connection.driver_class org.h2.Driver
#hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1
hibernate.connection.username sa
hibernate.connection.password
hibernate.connection.password
hibernate.tenant_identifier_resolver=org.hibernate.bugs.Resolver

hibernate.connection.pool_size 5

Expand Down