|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | + * Copyright Red Hat Inc. and Hibernate Authors |
| 4 | + */ |
| 5 | +package org.hibernate.processor.test.innerclass; |
| 6 | + |
| 7 | +import jakarta.persistence.Entity; |
| 8 | +import jakarta.persistence.EntityManager; |
| 9 | +import jakarta.persistence.GeneratedValue; |
| 10 | +import jakarta.persistence.Id; |
| 11 | +import org.hibernate.annotations.processing.Find; |
| 12 | +import org.hibernate.annotations.processing.HQL; |
| 13 | +import org.hibernate.processor.test.util.CompilationTest; |
| 14 | +import org.hibernate.processor.test.util.WithClasses; |
| 15 | +import org.junit.Test; |
| 16 | + |
| 17 | +import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor; |
| 18 | +import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfMethodInMetamodelFor; |
| 19 | +import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString; |
| 20 | + |
| 21 | +@WithClasses({InnerInterfaceTest.MyEntity.class, InnerInterfaceTest.Queries.class}) |
| 22 | +public class InnerInterfaceTest extends CompilationTest { |
| 23 | + |
| 24 | + @Entity |
| 25 | + public static class MyEntity { |
| 26 | + @Id |
| 27 | + @GeneratedValue |
| 28 | + public Long id; |
| 29 | + public String foo; |
| 30 | + } |
| 31 | + |
| 32 | + public interface Queries { |
| 33 | + @HQL("where foo = :foo") |
| 34 | + MyEntity findEntities(String foo); |
| 35 | + |
| 36 | + @Find |
| 37 | + MyEntity findEntitiesHql(String foo); |
| 38 | + } |
| 39 | + |
| 40 | + |
| 41 | + @Test |
| 42 | + public void test() { |
| 43 | + System.out.println( getMetaModelSourceAsString( InnerInterfaceTest.MyEntity.class ) ); |
| 44 | + System.out.println( getMetaModelSourceAsString( InnerInterfaceTest.Queries.class ) ); |
| 45 | + assertMetamodelClassGeneratedFor( InnerInterfaceTest.MyEntity.class ); |
| 46 | + assertMetamodelClassGeneratedFor( InnerInterfaceTest.Queries.class ); |
| 47 | + |
| 48 | + assertPresenceOfMethodInMetamodelFor( InnerInterfaceTest.Queries.class, "findEntities", |
| 49 | + EntityManager.class, String.class ); |
| 50 | + assertPresenceOfMethodInMetamodelFor( InnerInterfaceTest.Queries.class, "findEntitiesHql", |
| 51 | + EntityManager.class, String.class ); |
| 52 | + } |
| 53 | +} |
0 commit comments