Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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 );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ private void handleNamedQuery(AnnotationMirror mirror, boolean checkHql) {
context.getEntityNameMappings(), context.getEnumTypesByValue() )
);
if ( statement instanceof SqmSelectStatement
&& isQueryMethodName( name ) ) {
&& isQueryMethodName( name )
&& !isJakartaDataStyle() ) {
putMember( name,
// TODO: respect @NamedQuery(resultClass)
new NamedQueryMethod(
this,
(SqmSelectStatement<?>) statement,
Expand Down
Loading