Author: hardy.ferentschik
Date: 2010-05-12 13:17:45 -0400 (Wed, 12 May 2010)
New Revision: 19479
Added:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/AbstractEntity.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Person.java
Modified:
jpamodelgen/trunk/pom.xml
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/TypeUtils.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java
Log:
METAGEN-29 adding handling of type variables in AnnotationMetaEntity
Modified: jpamodelgen/trunk/pom.xml
===================================================================
--- jpamodelgen/trunk/pom.xml 2010-05-12 15:13:47 UTC (rev 19478)
+++ jpamodelgen/trunk/pom.xml 2010-05-12 17:17:45 UTC (rev 19479)
@@ -1,4 +1,6 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -90,6 +92,27 @@
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <executions>
+ <execution>
+ <id>enforce-java</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <!-- require JDK 1.6 to run the build -->
+ <version>[1.6,)</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-injection-plugin</artifactId>
<version>1.0.2</version>
@@ -202,7 +225,7 @@
<configuration>
<archive>
<manifestEntries>
- <Created-By>${java.version}
(${java.vendor})</Created-By>
+ <Created-By>${java.version}
(${java.vendor})</Created-By>
<Implementation-Title>${pom.name}</Implementation-Title>
<
Implementation-URL>http://www.jboss.org/</Implementation-URL>
<Implementation-Version>${pom.version}</Implementation-Version>
@@ -243,7 +266,9 @@
<autoVersionSubmodules>true</autoVersionSubmodules>
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
<remoteTagging>true</remoteTagging>
- <goals>package deploy javadoc:javadoc
org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:resources
org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:generate
assembly:assembly</goals>
+ <goals>package deploy javadoc:javadoc
org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:resources
+ org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:generate
assembly:assembly
+ </goals>
</configuration>
</plugin>
<plugin>
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2010-05-12
15:13:47 UTC (rev 19478)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2010-05-12
17:17:45 UTC (rev 19479)
@@ -35,6 +35,7 @@
import javax.lang.model.type.PrimitiveType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeVariable;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.SimpleTypeVisitor6;
import javax.persistence.AccessType;
@@ -215,6 +216,15 @@
return new AnnotationMetaSingleAttribute( parent, element, TypeUtils.toTypeString( t )
);
}
+ public AnnotationMetaAttribute visitTypeVariable(TypeVariable t, Element element) {
+ // METAGEN-29 - for a type variable we use the upper bound
+ TypeMirror mirror = t.getUpperBound();
+ TypeMirror erasedType = context.getTypeUtils().erasure( mirror );
+ return new AnnotationMetaSingleAttribute(
+ parent, element, erasedType.toString()
+ );
+ }
+
@Override
public AnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element
element) {
TypeElement returnedElement = ( TypeElement ) context.getTypeUtils().asElement(
declaredType );
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/TypeUtils.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/TypeUtils.java 2010-05-12
15:13:47 UTC (rev 19478)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/TypeUtils.java 2010-05-12
17:17:45 UTC (rev 19479)
@@ -206,7 +206,7 @@
if ( accessTypeInfo != null && accessTypeInfo.isAccessTypeResolved() ) {
context.logMessage(
Diagnostic.Kind.OTHER,
- "AccessType for " + searchedElement.toString() + "found in cache:
" + accessTypeInfo
+ "AccessType for " + searchedElement.toString() + " found in cache:
" + accessTypeInfo
);
return;
}
Added:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/AbstractEntity.java
===================================================================
---
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/AbstractEntity.java
(rev 0)
+++
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/AbstractEntity.java 2010-05-12
17:17:45 UTC (rev 19479)
@@ -0,0 +1,35 @@
+// $Id$
+/*
+* 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.inheritance;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public abstract class AbstractEntity<T> {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private T foo;
+
+ public AbstractEntity() {
+ }
+}
\ No newline at end of file
Property changes on:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/AbstractEntity.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java
===================================================================
---
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java 2010-05-12
15:13:47 UTC (rev 19478)
+++
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java 2010-05-12
17:17:45 UTC (rev 19479)
@@ -21,6 +21,8 @@
import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import static
org.hibernate.jpamodelgen.test.util.TestUtil.assertAttributeTypeInMetaModelFor;
+import static
org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
import static
org.hibernate.jpamodelgen.test.util.TestUtil.assertSuperClassRelationShipInMetamodel;
/**
@@ -29,14 +31,22 @@
*/
public class InheritanceTest extends CompilationTest {
@Test
- public void testSuperEntity() throws Exception {
+ public void testInheritance() throws Exception {
+
+ // entity inheritance
assertSuperClassRelationShipInMetamodel( Customer.class, User.class );
- }
- @Test
- public void testMappedSuperclass() throws Exception {
+
+ // mapped super class
assertSuperClassRelationShipInMetamodel( House.class, Building.class );
assertSuperClassRelationShipInMetamodel( Building.class, Area.class );
+
+ // METAGEN-29
+ assertSuperClassRelationShipInMetamodel( Person.class, AbstractEntity.class );
+ assertPresenceOfFieldInMetamodelFor( AbstractEntity.class, "foo",
"Property should exist - METAGEN-29" );
+ assertAttributeTypeInMetaModelFor(
+ AbstractEntity.class, "foo", Object.class, "Object is the upper bound
of foo "
+ );
}
@Override
Added:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Person.java
===================================================================
---
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Person.java
(rev 0)
+++
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Person.java 2010-05-12
17:17:45 UTC (rev 19479)
@@ -0,0 +1,40 @@
+// $Id$
+/*
+* 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.inheritance;
+
+import javax.persistence.Entity;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Person extends AbstractEntity<String> {
+ private String name;
+
+ protected Person() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id