HHH-13145 - Generated metamodel class can't be compiled.

This commit is contained in:
Sergey Morgunov 2018-12-07 03:12:12 +03:00 committed by Guillaume Smet
parent 77cdaa0824
commit b9edc8d323
4 changed files with 105 additions and 1 deletions

View File

@ -339,7 +339,7 @@ public class XmlMetaEntity implements MetaEntity {
return "java.lang.Double";
}
case DECLARED: {
return mirror.toString();
return ((DeclaredType)mirror).asElement().asType().toString();
}
case TYPEVAR: {
return mirror.toString();

View File

@ -0,0 +1,29 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.jpamodelgen.test.annotationtype;
import org.hibernate.jpamodelgen.test.util.CompilationTest;
import org.hibernate.jpamodelgen.test.util.TestForIssue;
import org.hibernate.jpamodelgen.test.util.TestUtil;
import org.hibernate.jpamodelgen.test.util.WithClasses;
import org.hibernate.jpamodelgen.test.util.WithMappingFiles;
import org.junit.Test;
/**
* @author Sergey Morgunov
*/
@TestForIssue(jiraKey = "HHH-13145")
public class AnnotationTypeTest extends CompilationTest {
@Test
@WithClasses({ Entity.class })
@WithMappingFiles("orm.xml")
public void testXmlConfiguredEntityGenerated() {
TestUtil.assertMetamodelClassGeneratedFor( Entity.class );
}
}

View File

@ -0,0 +1,47 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.jpamodelgen.test.annotationtype;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author Sergey Morgunov
*/
public class Entity {
private String id;
private String name;
public Entity(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public @Custom String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE})
@Retention(RetentionPolicy.CLASS)
public static @interface Custom {
}
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.jpamodelgen.test.annotationtype</package>
<entity class="Entity">
<table name="ENTITY"/>
<attributes>
<id name="id">
<column name="ID"/>
</id>
<basic name="name">
<column name="NAME"/>
</basic>
</attributes>
</entity>
</entity-mappings>