HHH-18106 - Test case
This commit is contained in:
parent
e73eb458b4
commit
8d2a0047e0
|
@ -0,0 +1,47 @@
|
|||
package org.hibernate.processor.test.constant;
|
||||
|
||||
import org.hibernate.processor.test.util.CompilationTest;
|
||||
import org.hibernate.processor.test.util.TestForIssue;
|
||||
import org.hibernate.processor.test.util.TestUtil;
|
||||
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;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-18106")
|
||||
public class ConstantInNamedQueryTest extends CompilationTest {
|
||||
|
||||
@Test
|
||||
@WithClasses(value = {}, sources = "org.hibernate.processor.test.constant.CookBookWithCheck")
|
||||
public void withCheckHQL() {
|
||||
final String entityClass = "org.hibernate.processor.test.constant.CookBookWithCheck";
|
||||
|
||||
System.out.println( TestUtil.getMetaModelSourceAsString( entityClass ) );
|
||||
|
||||
assertMetamodelClassGeneratedFor( entityClass );
|
||||
|
||||
assertPresenceOfFieldInMetamodelFor( entityClass, "QUERY_FIND_BAD_BOOKS" );
|
||||
assertPresenceOfFieldInMetamodelFor( entityClass, "QUERY_FIND_GOOD_BOOKS" );
|
||||
|
||||
assertPresenceOfMethodInMetamodelFor( entityClass, "findBadBooks", EntityManager.class );
|
||||
assertPresenceOfMethodInMetamodelFor( entityClass, "findGoodBooks", EntityManager.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithClasses(value = CookBookWithoutCheck.class, sources = "org.hibernate.processor.test.constant.NumericBookType")
|
||||
public void withoutCheckHQL() {
|
||||
final String entityClass = "org.hibernate.processor.test.constant.CookBookWithoutCheck";
|
||||
|
||||
System.out.println( TestUtil.getMetaModelSourceAsString( entityClass ) );
|
||||
|
||||
assertMetamodelClassGeneratedFor( entityClass );
|
||||
assertPresenceOfFieldInMetamodelFor( entityClass, "QUERY_FIND_GOOD_BOOKS" );
|
||||
|
||||
assertPresenceOfMethodInMetamodelFor( entityClass, "findGoodBooks", EntityManager.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.hibernate.processor.test.constant;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
|
||||
@Entity
|
||||
@NamedQuery(name = "#findGoodBooks",
|
||||
query = "from CookBookWithoutCheck where bookType = org.hibernate.processor.test.constant.NumericBookType.GOOD")
|
||||
public class CookBookWithoutCheck {
|
||||
|
||||
@Id
|
||||
String isbn;
|
||||
String title;
|
||||
int bookType;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.hibernate.processor.test.constant;
|
||||
|
||||
import org.hibernate.annotations.processing.CheckHQL;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
|
||||
@Entity
|
||||
@CheckHQL
|
||||
@NamedQuery(name = "#findGoodBooks",
|
||||
query = "from CookBookWithCheck where bookType = org.hibernate.processor.test.constant.CookBookWithCheck.GOOD")
|
||||
@NamedQuery(name = "#findBadBooks",
|
||||
query = "from CookBookWithCheck where bookType = 0")
|
||||
public class CookBookWithCheck {
|
||||
|
||||
public static final int GOOD = 1;
|
||||
public static final int BAD = 0;
|
||||
public static final int UGLY = -1;
|
||||
|
||||
@Id
|
||||
String isbn;
|
||||
String title;
|
||||
int bookType;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hibernate.processor.test.constant;
|
||||
|
||||
public class NumericBookType {
|
||||
public static final Integer GOOD = 1;
|
||||
public static final Integer BAD = 0;
|
||||
public static final Integer UGLY = -1;
|
||||
}
|
Loading…
Reference in New Issue