HHH-18945 Test case - entity class extends mapped superclass with same simple class name

This commit is contained in:
Čedomir Igaly 2024-12-16 13:02:46 +01:00 committed by Gavin King
parent 9ce2960b81
commit 92e29b63db
3 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,34 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.classnamecollision;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
import static org.hibernate.processor.test.util.TestUtil.getMetamodelClassFor;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ClassNameCollisionTest extends CompilationTest {
@Test
@WithClasses({
Something.class,
org.hibernate.processor.test.classnamecollision.somewhere.Something.class
})
public void testAmbiguousSimpleName() {
System.out.println( getMetaModelSourceAsString( Something.class ) );
assertMetamodelClassGeneratedFor( Something.class );
System.out.println( getMetaModelSourceAsString( org.hibernate.processor.test.classnamecollision.somewhere.Something.class ) );
assertMetamodelClassGeneratedFor( org.hibernate.processor.test.classnamecollision.somewhere.Something.class );
assertEquals(
getMetamodelClassFor( org.hibernate.processor.test.classnamecollision.somewhere.Something.class ).getName(),
getMetamodelClassFor( Something.class ).getSuperclass()
.getName() );
}
}

View File

@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.classnamecollision;
import jakarta.persistence.Entity;
@Entity
public class Something extends org.hibernate.processor.test.classnamecollision.somewhere.Something {
String alphaValue;
}

View File

@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.classnamecollision.somewhere;
import jakarta.persistence.MappedSuperclass;
@MappedSuperclass
abstract public class Something {
String name;
}