HHH-18761 add test
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
eaca728d60
commit
383d32e3e6
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.namedquery;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
|
||||
@NamedQuery(name = "#things",
|
||||
query = "from Thing where name like :name")
|
||||
@Entity
|
||||
public class Thing {
|
||||
@Id @GeneratedValue long id;
|
||||
String name;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.namedquery;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
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.assertPresenceOfFieldInMetamodelFor;
|
||||
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfMethodInMetamodelFor;
|
||||
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
|
||||
|
||||
public class ThingTest extends CompilationTest {
|
||||
@Test @WithClasses( Thing.class )
|
||||
public void test() {
|
||||
System.out.println( getMetaModelSourceAsString( Thing.class) );
|
||||
System.out.println( getMetaModelSourceAsString( Thing.class, true) );
|
||||
assertMetamodelClassGeneratedFor(Thing.class);
|
||||
assertMetamodelClassGeneratedFor(Thing.class, true);
|
||||
assertPresenceOfMethodInMetamodelFor( Thing.class, "things", EntityManager.class, String.class );
|
||||
}
|
||||
}
|
|
@ -107,7 +107,8 @@ public abstract class AnnotationMeta implements Metamodel {
|
|||
if ( statement instanceof SqmSelectStatement
|
||||
&& isQueryMethodName( name ) ) {
|
||||
putMember( name,
|
||||
new NamedQueryMethod(
|
||||
// TODO: respect @NamedQuery(resultClass)
|
||||
new NamedQueryMethod(
|
||||
this,
|
||||
(SqmSelectStatement<?>) statement,
|
||||
name.substring(1),
|
||||
|
|
Loading…
Reference in New Issue