|
| 1 | +/* |
| 2 | + * Hibernate, Relational Persistence for Idiomatic Java |
| 3 | + * |
| 4 | + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
| 5 | + * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 6 | + */ |
| 7 | +package org.hibernate.test.mapping; |
| 8 | + |
| 9 | +import java.io.Serializable; |
| 10 | +import java.util.Objects; |
| 11 | +import javax.persistence.Entity; |
| 12 | +import javax.persistence.Id; |
| 13 | +import javax.persistence.IdClass; |
| 14 | +import javax.persistence.MappedSuperclass; |
| 15 | + |
| 16 | +import org.hibernate.testing.TestForIssue; |
| 17 | +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; |
| 18 | +import org.junit.Test; |
| 19 | + |
| 20 | +@TestForIssue(jiraKey = "HHH-14499") |
| 21 | +public class MappedSuperclassWithGenericsTest extends BaseCoreFunctionalTestCase { |
| 22 | + |
| 23 | + @Override |
| 24 | + protected Class<?>[] getAnnotatedClasses() { |
| 25 | + return new Class[] { |
| 26 | + IntermediateAbstractMapped.class, |
| 27 | + BaseEntity.class, |
| 28 | + AbstractGenericMappedSuperType.class, |
| 29 | + }; |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void testIt() { |
| 34 | + |
| 35 | + } |
| 36 | + |
| 37 | + @MappedSuperclass |
| 38 | + public static abstract class AbstractGenericMappedSuperType<T> { |
| 39 | + |
| 40 | + private T whateverType; |
| 41 | + |
| 42 | + } |
| 43 | + |
| 44 | + @MappedSuperclass |
| 45 | + @IdClass(PK.class) |
| 46 | + public static abstract class IntermediateAbstractMapped<T> extends AbstractGenericMappedSuperType<T> { |
| 47 | + |
| 48 | + @Id |
| 49 | + private String keyOne; |
| 50 | + @Id |
| 51 | + private String keyTwo; |
| 52 | + @Id |
| 53 | + private String keyThree; |
| 54 | + } |
| 55 | + |
| 56 | + @SuppressWarnings("UnusedDeclaration") |
| 57 | + public static class PK implements Serializable { |
| 58 | + |
| 59 | + private String keyOne; |
| 60 | + private String keyTwo; |
| 61 | + private String keyThree; |
| 62 | + |
| 63 | + @Override |
| 64 | + public boolean equals(Object o) { |
| 65 | + if ( this == o ) { |
| 66 | + return true; |
| 67 | + } |
| 68 | + if ( o == null || getClass() != o.getClass() ) { |
| 69 | + return false; |
| 70 | + } |
| 71 | + PK pk = (PK) o; |
| 72 | + return Objects.equals( keyOne, pk.keyOne ) && |
| 73 | + Objects.equals( keyTwo, pk.keyTwo ) && |
| 74 | + Objects.equals( keyThree, pk.keyThree ); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public int hashCode() { |
| 79 | + return Objects.hash( keyOne, keyTwo, keyThree ); |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + @Entity(name = "BaseEntity") |
| 84 | + public static class BaseEntity<T> extends IntermediateAbstractMapped<byte[]> { |
| 85 | + |
| 86 | + String aString; |
| 87 | + |
| 88 | + } |
| 89 | + |
| 90 | +} |
0 commit comments