HHH-18278 - Test case:

Metamodel generator should generate classes
			org.hibernate.processor.test.packageinfo.Message_
		and
			org.hibernate.processor.test.packageinfo.packageinfo_
		With later containing fields QUERY_FIND_BY_KEY and QUERY_FIND_BY_ID_AND_KEY,
		and method findByKey
This commit is contained in:
Čedomir Igaly 2024-06-17 16:57:13 +02:00 committed by Gavin King
parent 05dc7b2612
commit 62a89e6d30
3 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package org.hibernate.processor.test.packageinfo;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import jakarta.persistence.EntityManager;
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 PackageInfoMetamodelTest extends CompilationTest {
@Test
@WithClasses(value = {}, sources = {
"org.hibernate.processor.test.packageinfo.Message",
"org.hibernate.processor.test.packageinfo.package-info"
})
public void test() {
assertMetamodelClassGeneratedFor( "org.hibernate.processor.test.packageinfo.Message" );
System.out.println( getMetaModelSourceAsString( "org.hibernate.processor.test.packageinfo.packageinfo" ) );
assertPresenceOfFieldInMetamodelFor(
"org.hibernate.processor.test.packageinfo.packageinfo",
"QUERY_FIND_BY_KEY"
);
assertPresenceOfFieldInMetamodelFor(
"org.hibernate.processor.test.packageinfo.packageinfo",
"QUERY_FIND_BY_ID_AND_KEY"
);
assertPresenceOfMethodInMetamodelFor(
"org.hibernate.processor.test.packageinfo.packageinfo",
"findByKey",
EntityManager.class,
String.class
);
}
}

View File

@ -0,0 +1,13 @@
package org.hibernate.processor.test.packageinfo;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@Entity
public class Message {
@Id
Integer id;
String key;
}

View File

@ -0,0 +1,10 @@
@NamedQuery(
name = "#findByKey",
query = "from Message where key=:key")
@NamedQuery(
name = "findByIdAndKey",
query = "from Message where id=:id and key=:key")
package org.hibernate.processor.test.packageinfo;
import org.hibernate.annotations.NamedQuery;