mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
METAGEN-91 Making sure that field annotated with @EmbeddedId gets added as singular attribute
Updating tests
This commit is contained in:
parent
44aaa41339
commit
cac6d00342
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
## Latest stable version
|
## Latest stable version
|
||||||
|
|
||||||
*1.2.0.Final, 06.03.2012*
|
*1.3.0.Final, 09.08.2013*
|
||||||
|
|
||||||
## What is it?
|
## What is it?
|
||||||
|
|
||||||
The Hibernate JPA 2 Metamodel Generator is a Java 6 annotation processor generating meta model classes for JPA 2 type-safe criteria queries.
|
The Hibernate JPA 2 Metamodel Generator is a Java 6 annotation processor generating meta model classes for JPA 2 type-safe criteria queries.
|
||||||
|
|
||||||
The processor (*JPAMetaModelEntityProcessor*) processes classes annotated with *@Entity*, *@MappedSuperclass* or *@Embeddable*, as well as entities mapped in */META-INF/orm.xml* and mapping files specified in *persistence.xml*.
|
The processor, *JPAMetaModelEntityProcessor*, processes classes annotated with *@Entity*, *@MappedSuperclass* or *@Embeddable*, as well as entities mapped in */META-INF/orm.xml* and mapping files specified in *persistence.xml*.
|
||||||
|
|
||||||
## System Requirements
|
## System Requirements
|
||||||
|
|
||||||
|
@ -1,6 +1,23 @@
|
|||||||
Hibernate JPA 2 Metamodel Generator Changelog
|
Hibernate JPA 2 Metamodel Generator Changelog
|
||||||
=============================================
|
=============================================
|
||||||
|
|
||||||
|
1.3.0.Final (09.08.2013)
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
** Bug
|
||||||
|
* [METAGEN-81] - @Embeddable entities don't inherit the access type if it comes from the hierarchy of the containing class
|
||||||
|
* [METAGEN-82] - Inconsistencies in the way @MappedSuperClass entities are considered
|
||||||
|
* [METAGEN-85] - MixedConfigurationTest failing
|
||||||
|
* [METAGEN-86] - Generator exits when discovering <xml-mapping-metadata-complete/> in ANY persistence unit
|
||||||
|
* [METAGEN-88] - End of line in DOS format is hard-coded on ImportContextImpl on "Hibernate Metamodel Generator"
|
||||||
|
* [METAGEN-90] - Wrong typed metamodel SetAttribute (using an implemented interface)
|
||||||
|
* [METAGEN-91] - Metamodel generation miss embedded id field if class extends a mapped super class
|
||||||
|
* [METAGEN-92] - Hibernate Metamodel Generator is not aware of persistence.xml for JPA 2.1
|
||||||
|
* [METAGEN-94] - MappedSuperclassWithoutExplicitIdTest failing on certain operating systems
|
||||||
|
|
||||||
|
** Task
|
||||||
|
* [METAGEN-83] - Upgrade version
|
||||||
|
|
||||||
1.2.0.Final (06.03.2012)
|
1.2.0.Final (06.03.2012)
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||||
<version>1.3.0-SNAPSHOT</version>
|
<version>1.4.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>Hibernate JPA 2 Metamodel Generator</name>
|
<name>Hibernate JPA 2 Metamodel Generator</name>
|
||||||
<description>Annotation Processor to generate JPA 2 static metamodel classes</description>
|
<description>Annotation Processor to generate JPA 2 static metamodel classes</description>
|
||||||
@ -28,7 +28,8 @@
|
|||||||
<connection>scm:git:git://github.com/hibernate/hibernate-metamodelgen.git</connection>
|
<connection>scm:git:git://github.com/hibernate/hibernate-metamodelgen.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:hibernate/hibernate-metamodelgen.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:hibernate/hibernate-metamodelgen.git</developerConnection>
|
||||||
<url>http://github.com/hibernate/hibernate-metamodelgen</url>
|
<url>http://github.com/hibernate/hibernate-metamodelgen</url>
|
||||||
</scm>
|
<tag>HEAD</tag>
|
||||||
|
</scm>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
@ -381,7 +382,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</pluginExecutionFilter>
|
</pluginExecutionFilter>
|
||||||
<action>
|
<action>
|
||||||
<ignore></ignore>
|
<ignore />
|
||||||
</action>
|
</action>
|
||||||
</pluginExecution>
|
</pluginExecution>
|
||||||
</pluginExecutions>
|
</pluginExecutions>
|
||||||
|
@ -177,7 +177,9 @@ public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element p) {
|
|||||||
private boolean isBasicAttribute(Element element, Element returnedElement) {
|
private boolean isBasicAttribute(Element element, Element returnedElement) {
|
||||||
if ( TypeUtils.containsAnnotation( element, Constants.BASIC )
|
if ( TypeUtils.containsAnnotation( element, Constants.BASIC )
|
||||||
|| TypeUtils.containsAnnotation( element, Constants.ONE_TO_ONE )
|
|| TypeUtils.containsAnnotation( element, Constants.ONE_TO_ONE )
|
||||||
|| TypeUtils.containsAnnotation( element, Constants.MANY_TO_ONE ) ) {
|
|| TypeUtils.containsAnnotation( element, Constants.MANY_TO_ONE )
|
||||||
|
|| TypeUtils.containsAnnotation( element, Constants.EMBEDDED_ID )
|
||||||
|
|| TypeUtils.containsAnnotation( element, Constants.ID )) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.hibernate.jpamodelgen.test.embeddedid.withinheritance;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
public class AbstractRef implements Serializable {
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
protected AbstractRef() {
|
||||||
|
// required by JPA
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractRef(final int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* JBoss, Home of Professional Open Source
|
||||||
|
* Copyright 2010, Red Hat Middleware LLC, and individual contributors
|
||||||
|
* by the @authors tag. See the copyright.txt in the distribution for a
|
||||||
|
* full listing of individual contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.hibernate.jpamodelgen.test.embeddedid.withinheritance;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.jpamodelgen.test.util.CompilationTest;
|
||||||
|
import org.hibernate.jpamodelgen.test.util.TestUtil;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
|
||||||
|
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
public class EmbeddedIdWithInheritanceTest extends CompilationTest {
|
||||||
|
@Test
|
||||||
|
public void testEntityContainsEmbeddedIdProperty() {
|
||||||
|
assertMetamodelClassGeneratedFor( TestEntity.class );
|
||||||
|
assertPresenceOfFieldInMetamodelFor(
|
||||||
|
TestEntity.class, "ref", "Property ref should be in metamodel"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getPackageNameOfCurrentTest() {
|
||||||
|
return EmbeddedIdWithInheritanceTest.class.getPackage().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<String> getOrmFiles() {
|
||||||
|
List<String> ormFiles = new ArrayList<String>();
|
||||||
|
String dir = TestUtil.fcnToPath( EmbeddedIdWithInheritanceTest.class.getPackage().getName() );
|
||||||
|
ormFiles.add( dir + "/orm.xml" );
|
||||||
|
return ormFiles;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.hibernate.jpamodelgen.test.embeddedid.withinheritance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
public class Ref extends AbstractRef {
|
||||||
|
public Ref() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ref(int id) {
|
||||||
|
super( id );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
package org.hibernate.jpamodelgen.test.embeddedid.withinheritance;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.EmbeddedId;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Immutable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Immutable
|
||||||
|
@Table(name = "ENTITY")
|
||||||
|
public class TestEntity implements Serializable {
|
||||||
|
@EmbeddedId
|
||||||
|
private Ref ref;
|
||||||
|
|
||||||
|
@Column(name = "NAME", insertable = false, updatable = false, unique = true)
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -31,7 +31,7 @@
|
|||||||
/**
|
/**
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
public class EmbeddedIdTest extends CompilationTest {
|
public class EmbeddedIdNoInheritanceTest extends CompilationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGeneratedAnnotationNotGenerated() {
|
public void testGeneratedAnnotationNotGenerated() {
|
||||||
assertMetamodelClassGeneratedFor( Person.class );
|
assertMetamodelClassGeneratedFor( Person.class );
|
||||||
@ -55,13 +55,13 @@ public void testGeneratedAnnotationNotGenerated() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getPackageNameOfCurrentTest() {
|
protected String getPackageNameOfCurrentTest() {
|
||||||
return EmbeddedIdTest.class.getPackage().getName();
|
return EmbeddedIdNoInheritanceTest.class.getPackage().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<String> getOrmFiles() {
|
protected Collection<String> getOrmFiles() {
|
||||||
List<String> ormFiles = new ArrayList<String>();
|
List<String> ormFiles = new ArrayList<String>();
|
||||||
String dir = TestUtil.fcnToPath( EmbeddedIdTest.class.getPackage().getName() );
|
String dir = TestUtil.fcnToPath( EmbeddedIdNoInheritanceTest.class.getPackage().getName() );
|
||||||
ormFiles.add( dir + "/orm.xml" );
|
ormFiles.add( dir + "/orm.xml" );
|
||||||
return ormFiles;
|
return ormFiles;
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||||
|
|
||||||
import javax.persistence.EmbeddedId;
|
import javax.persistence.EmbeddedId;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||||
|
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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 http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
|
||||||
|
version="2.0">
|
||||||
|
|
||||||
|
<mapped-superclass class="org.hibernate.jpamodelgen.test.embeddedid.withinheritance.AbstractRef">
|
||||||
|
<attributes>
|
||||||
|
<basic name="id">
|
||||||
|
<column name="ID" insertable="false" updatable="false" nullable="false"/>
|
||||||
|
</basic>
|
||||||
|
</attributes>
|
||||||
|
</mapped-superclass>
|
||||||
|
|
||||||
|
<embeddable class="org.hibernate.jpamodelgen.test.embeddedid.withinheritance.Ref">
|
||||||
|
</embeddable>
|
||||||
|
|
||||||
|
</entity-mappings>
|
@ -6,13 +6,13 @@
|
|||||||
version="2.0"
|
version="2.0"
|
||||||
>
|
>
|
||||||
<package>org.hibernate.jpamodelgen.test.embeddedid</package>
|
<package>org.hibernate.jpamodelgen.test.embeddedid</package>
|
||||||
<entity class="XmlPerson" access="FIELD">
|
<entity class="org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance.XmlPerson" access="FIELD">
|
||||||
<attributes>
|
<attributes>
|
||||||
<embedded-id name="id"/>
|
<embedded-id name="id"/>
|
||||||
<basic name="address"/>
|
<basic name="address"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</entity>
|
</entity>
|
||||||
<embeddable class="PersonId">
|
<embeddable class="org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance.PersonId">
|
||||||
<attributes>
|
<attributes>
|
||||||
<basic name="name"/>
|
<basic name="name"/>
|
||||||
<basic name="snn"/>
|
<basic name="snn"/>
|
Loading…
x
Reference in New Issue
Block a user