Skip to content

Commit

Permalink
HHH-18819 Add test for issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel committed Jan 8, 2025
1 parent 4115f97 commit 893fdd1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
Person.class,
Measurement.class,
Height.class,
WeightClass.class,
Weight.class,
} )
public class EmbeddableMetaModelTest {
@Test
Expand Down Expand Up @@ -60,4 +62,18 @@ public void test(EntityManagerFactoryScope scope) {
assertNotNull( Measurement_.unit );
} );
}

@Test
@Jira( "https://hibernate.atlassian.net/browse/HHH-18819" )
public void testIdClass(EntityManagerFactoryScope scope) {
scope.inTransaction( entityManager -> {
final EmbeddableDomainType<Weight> embeddable = (EmbeddableDomainType<Weight>) entityManager.getMetamodel()
.embeddable( Weight.class );
assertNotNull( embeddable.getSuperType() );
assertEquals( MAPPED_SUPERCLASS, embeddable.getSuperType().getPersistenceType() );
assertEquals( Measurement.class, embeddable.getSuperType().getJavaType() );
assertNotNull( Weight_.weight );
assertNotNull( Measurement_.unit );
} );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.orm.test.metamodel;

import jakarta.persistence.Embeddable;

/**
* @author Marco Belladelli
*/
@Embeddable
public class Weight extends Measurement {
private float weight;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.orm.test.metamodel;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;

/**
* @author Marco Belladelli
*/
@Entity
@IdClass(Weight.class)
public class WeightClass {
@Id
private String unit;

@Id
private float weight;

private String description;
}

0 comments on commit 893fdd1

Please sign in to comment.