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
|
||||
|
||||
*1.2.0.Final, 06.03.2012*
|
||||
*1.3.0.Final, 09.08.2013*
|
||||
|
||||
## 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 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
|
||||
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
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)
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
|
||||
<name>Hibernate JPA 2 Metamodel Generator</name>
|
||||
<description>Annotation Processor to generate JPA 2 static metamodel classes</description>
|
||||
|
@ -28,6 +28,7 @@
|
|||
<connection>scm:git:git://github.com/hibernate/hibernate-metamodelgen.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:hibernate/hibernate-metamodelgen.git</developerConnection>
|
||||
<url>http://github.com/hibernate/hibernate-metamodelgen</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@ -381,7 +382,7 @@
|
|||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore></ignore>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
|
|
|
@ -177,7 +177,9 @@ public class MetaAttributeGenerationVisitor extends SimpleTypeVisitor6<Annotatio
|
|||
private boolean isBasicAttribute(Element element, Element returnedElement) {
|
||||
if ( TypeUtils.containsAnnotation( element, Constants.BASIC )
|
||||
|| 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
||||
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -31,7 +31,7 @@ import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfField
|
|||
/**
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class EmbeddedIdTest extends CompilationTest {
|
||||
public class EmbeddedIdNoInheritanceTest extends CompilationTest {
|
||||
@Test
|
||||
public void testGeneratedAnnotationNotGenerated() {
|
||||
assertMetamodelClassGeneratedFor( Person.class );
|
||||
|
@ -55,13 +55,13 @@ public class EmbeddedIdTest extends CompilationTest {
|
|||
|
||||
@Override
|
||||
protected String getPackageNameOfCurrentTest() {
|
||||
return EmbeddedIdTest.class.getPackage().getName();
|
||||
return EmbeddedIdNoInheritanceTest.class.getPackage().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getOrmFiles() {
|
||||
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" );
|
||||
return ormFiles;
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
||||
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
||||
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.hibernate.jpamodelgen.test.embeddedid;
|
||||
package org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance;
|
||||
|
||||
/**
|
||||
* @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"
|
||||
>
|
||||
<package>org.hibernate.jpamodelgen.test.embeddedid</package>
|
||||
<entity class="XmlPerson" access="FIELD">
|
||||
<entity class="org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance.XmlPerson" access="FIELD">
|
||||
<attributes>
|
||||
<embedded-id name="id"/>
|
||||
<basic name="address"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
<embeddable class="PersonId">
|
||||
<embeddable class="org.hibernate.jpamodelgen.test.embeddedid.withoutinheritance.PersonId">
|
||||
<attributes>
|
||||
<basic name="name"/>
|
||||
<basic name="snn"/>
|
Loading…
Reference in New Issue