Author: epbernard
Date: 2009-07-09 07:45:57 -0400 (Thu, 09 Jul 2009)
New Revision: 17057
Modified:
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java
jpamodelgen/trunk/test/src/main/java/model/Area.java
jpamodelgen/trunk/test/src/test/java/tests/AccessTypeTest.java
Log:
Add support for default access type for mapped superclass objects
Modified:
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java
===================================================================
---
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java 2009-07-09
09:53:56 UTC (rev 17056)
+++
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java 2009-07-09
11:45:57 UTC (rev 17057)
@@ -111,9 +111,21 @@
//pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA property",
mymember);
}
}
+ }
+ //process superclasses
+ for(TypeElement superclass = TypeUtils.getSuperclass(element) ;
+ superclass != null ;
+ superclass = TypeUtils.getSuperclass( superclass ) ) {
+ if ( superclass.getAnnotation( Entity.class ) != null ) {
+ break; //will be handled or has been handled already
+ }
+ else if ( superclass.getAnnotation( MappedSuperclass.class ) != null ) {
+ context.processElement( superclass, defaultAccessTypeForHierarchy );
+ }
}
+
if ( members.size() == 0 ) {
pe.getMessager().printMessage( Kind.WARNING, "No properties found on " +
element, element );
}
Modified: jpamodelgen/trunk/test/src/main/java/model/Area.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/model/Area.java 2009-07-09 09:53:56 UTC (rev
17056)
+++ jpamodelgen/trunk/test/src/main/java/model/Area.java 2009-07-09 11:45:57 UTC (rev
17057)
@@ -11,6 +11,11 @@
private int width;
private int height;
+ //should not be persistent
+ public int getVolume() {
+ return length*width*height;
+ }
+
public int getLength() {
return length;
}
Modified: jpamodelgen/trunk/test/src/test/java/tests/AccessTypeTest.java
===================================================================
--- jpamodelgen/trunk/test/src/test/java/tests/AccessTypeTest.java 2009-07-09 09:53:56 UTC
(rev 17056)
+++ jpamodelgen/trunk/test/src/test/java/tests/AccessTypeTest.java 2009-07-09 11:45:57 UTC
(rev 17057)
@@ -27,7 +27,12 @@
absenceOfField( "model.Detail_", "nonPersistent " );
}
+ @Test
+ public void testDefaultAccessTypeForMappedSuperclass() throws Exception{
+ absenceOfField( "model.Detail_", "volume" );
+ }
+
private void absenceOfField(String className, String fieldName) throws
ClassNotFoundException {
Class<?> user_ = Class.forName( className );
try {
Show replies by date