Skip to content

Commit

Permalink
HHH-18693 Test with "ugly" named entity
Browse files Browse the repository at this point in the history
  • Loading branch information
cigaly committed Nov 17, 2024
1 parent d62d7fc commit 255abee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
*/
package org.hibernate.processor.test.innerclass;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.NamedQuery;
Expand Down Expand Up @@ -79,4 +81,22 @@ public void setCity(String city) {

public abstract void setName(String name);
}

@Entity(name = "The Person")
@NamedQuery(
name = "#selectThePersonName",
query = "select `upper`(`the person`.`name`) as `The person name` from `The Person` `the person`"
)
public static class ThePerson {

@Id
@GeneratedValue
Integer id;

@Column(name = "the name")
String name;

@Column
String surname;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.hibernate.processor.test.innerclass;

import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.Id;
import jakarta.persistence.NamedQuery;
import org.hibernate.processor.test.util.CompilationTest;
Expand All @@ -13,6 +14,8 @@

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor;
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 InnerClassTest extends CompilationTest {
Expand All @@ -31,6 +34,10 @@ public void test() {
assertNoMetamodelClassGeneratedFor( Dummy.class );
assertMetamodelClassGeneratedFor( Dummy.DummyEmbeddable.class );
System.out.println( getMetaModelSourceAsString( Dummy.DummyEmbeddable.class ) );
assertMetamodelClassGeneratedFor( Dummy.ThePerson.class );
System.out.println( getMetaModelSourceAsString( Dummy.ThePerson.class ) );
assertPresenceOfFieldInMetamodelFor( Dummy.ThePerson.class, "QUERY_SELECT_THE_PERSON_NAME" );
assertPresenceOfMethodInMetamodelFor( Dummy.ThePerson.class, "selectThePersonName", EntityManager.class );
}

@Entity(name = "Inner")
Expand Down

0 comments on commit 255abee

Please sign in to comment.