Skip to content

Commit 743691e

Browse files
committed
HHH-18761 add test
Signed-off-by: Gavin King <[email protected]>
1 parent fb7602a commit 743691e

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.namedquery;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.NamedQuery;
11+
12+
@NamedQuery(name = "#things",
13+
query = "from Thing where name like :name")
14+
@Entity
15+
public class Thing {
16+
@Id @GeneratedValue long id;
17+
String name;
18+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.namedquery;
6+
7+
import jakarta.persistence.EntityManager;
8+
import org.hibernate.processor.test.util.CompilationTest;
9+
import org.hibernate.processor.test.util.WithClasses;
10+
import org.junit.Test;
11+
12+
import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
13+
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
14+
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfMethodInMetamodelFor;
15+
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
16+
17+
public class ThingTest extends CompilationTest {
18+
@Test @WithClasses( Thing.class )
19+
public void test() {
20+
System.out.println( getMetaModelSourceAsString( Thing.class) );
21+
System.out.println( getMetaModelSourceAsString( Thing.class, true) );
22+
assertMetamodelClassGeneratedFor(Thing.class);
23+
assertMetamodelClassGeneratedFor(Thing.class, true);
24+
assertPresenceOfMethodInMetamodelFor( Thing.class, "things", EntityManager.class, String.class );
25+
assertPresenceOfFieldInMetamodelFor( Thing.class, "__things_" );
26+
}
27+
}

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMeta.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private void handleNamedQuery(AnnotationMirror mirror, boolean checkHql) {
113113
&& statement instanceof SqmSelectStatement<?> selectStatement ) {
114114
if ( isQueryMethodName( name ) ) {
115115
putMember( name,
116+
// TODO: respect @NamedQuery(resultClass)
116117
new NamedQueryMethod(
117118
this,
118119
selectStatement,

0 commit comments

Comments
 (0)