HHH-18868 Adapted test case from https://hibernate.atlassian.net/browse/HHH-18868
This commit is contained in:
parent
c88b1e8cc9
commit
be2551154f
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.hhh18868;
|
||||
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.IdClass;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
|
||||
@IdClass(PKey.class)
|
||||
@MappedSuperclass
|
||||
public class BaseSummary implements Serializable {
|
||||
|
||||
@Id
|
||||
private Integer year;
|
||||
@Id
|
||||
private Integer month;
|
||||
private BigDecimal value;
|
||||
|
||||
public Integer getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(Integer year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public Integer getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(Integer month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public BigDecimal getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
BaseSummary that = (BaseSummary) o;
|
||||
return Objects.equals( year, that.year ) && Objects.equals( month, that.month );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( year, month );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.hhh18868;
|
||||
|
||||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DomainModel(annotatedClasses = {Summary.class, BaseSummary.class})
|
||||
@SessionFactory
|
||||
@JiraKey( "HHH-18858" )
|
||||
public class HHH18868Test {
|
||||
|
||||
@Test
|
||||
public void test(SessionFactoryScope scope) {
|
||||
scope.inSession( entityManager -> {
|
||||
final var yearAttribute = Summary_.year.getDeclaringType().getAttribute( "year" );
|
||||
assertThat( yearAttribute ).isEqualTo( Summary_.year );
|
||||
assertThat( ((SingularAttribute<?, ?>) yearAttribute).isId() ).isTrue();
|
||||
|
||||
final var monthAttribute = Summary_.month.getDeclaringType().getAttribute( "month" );
|
||||
assertThat( monthAttribute ).isEqualTo( Summary_.month );
|
||||
assertThat( ((SingularAttribute<?, ?>) monthAttribute).isId() ).isTrue();
|
||||
} );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.hhh18868;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PKey implements Serializable {
|
||||
|
||||
private Integer year;
|
||||
private Integer month;
|
||||
|
||||
public Integer getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(Integer year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public Integer getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(Integer month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
PKey pKey = (PKey) o;
|
||||
return Objects.equals( year, pKey.year ) && Objects.equals( month, pKey.month );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( year, month );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.hhh18868;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Summary extends BaseSummary {
|
||||
}
|
Loading…
Reference in New Issue