[hibernate-commits] Hibernate SVN: r17899 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/annotation and 19 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Nov 3 09:52:07 EST 2009


Author: hardy.ferentschik
Date: 2009-11-03 09:52:05 -0500 (Tue, 03 Nov 2009)
New Revision: 17899

Added:
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
   jpamodelgen/trunk/src/test/java/org/
   jpamodelgen/trunk/src/test/java/org/hibernate/
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTypeTest.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/InheritanceTest.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappingTest.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Image.java
   jpamodelgen/trunk/src/test/resources/org/
   jpamodelgen/trunk/src/test/resources/org/hibernate/
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml
   jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml
Removed:
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java
   jpamodelgen/trunk/src/test/java/model/
   jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java
   jpamodelgen/trunk/src/test/java/test/InheritanceTest.java
   jpamodelgen/trunk/src/test/java/test/QueryTest.java
   jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java
   jpamodelgen/trunk/src/test/resources/model/xmlmapped/
Modified:
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java
   jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Address.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Area.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Building.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Country.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Customer.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Detail.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hominidae.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/House.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Human.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Inhabitant.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Item.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/LivingBeing.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Mammals.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Order.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pet.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Product.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Shop.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/User.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Address.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Building.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/LivingBeing.java
   jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Mammal.java
   jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml
   jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml
   jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml
   jpamodelgen/trunk/src/test/resources/META-INF/orm.xml
   jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml
   jpamodelgen/trunk/src/test/suite/unit-tests.xml
Log:
METAGEN-3

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -24,7 +24,6 @@
 import java.util.List;
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.annotation.processing.FilerException;
-import javax.annotation.Generated;
 import javax.tools.FileObject;
 import javax.tools.Diagnostic;
 import javax.lang.model.type.TypeMirror;
@@ -38,7 +37,7 @@
  */
 public class ClassWriter {
 	
-	public static void writeFile(IMetaEntity entity, ProcessingEnvironment processingEnv, Context context) {
+	public static void writeFile(MetaEntity entity, ProcessingEnvironment processingEnv, Context context) {
 		try {
 			String metaModelPackage = entity.getPackageName();
 
@@ -85,7 +84,7 @@
 	 *
 	 * @return body content
 	 */
-	private static StringBuffer generateBody(IMetaEntity entity, Context context) {
+	private static StringBuffer generateBody(MetaEntity entity, Context context) {
 
 		StringWriter sw = new StringWriter();
 		PrintWriter pw = null;
@@ -103,9 +102,9 @@
 
 			pw.println();
 
-			List<IMetaAttribute> members = entity.getMembers();
+			List<MetaAttribute> members = entity.getMembers();
 
-			for ( IMetaAttribute metaMember : members ) {
+			for ( MetaAttribute metaMember : members ) {
 				pw.println( "	" + metaMember.getDeclarationString() );
 			}
 			pw.println();
@@ -119,7 +118,7 @@
 		}
 	}
 
-	private static void printClassDeclaration(IMetaEntity entity, PrintWriter pw, Context context) {
+	private static void printClassDeclaration(MetaEntity entity, PrintWriter pw, Context context) {
 		pw.print( "public abstract class " + entity.getSimpleName() + "_" );
 
 		final TypeMirror superClass = entity.getTypeElement().getSuperclass();

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/Context.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -26,7 +26,7 @@
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.tools.Diagnostic;
 
-import org.hibernate.jpamodelgen.annotation.MetaEntity;
+import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity;
 
 /**
  * @author Max Andersen
@@ -38,8 +38,8 @@
 	private Map<TypeElement, AccessTypeHolder> accessTypes = new HashMap<TypeElement, AccessTypeHolder>();
 	private Set<String> elementsAlreadyProcessed = new HashSet<String>();
 	private ProcessingEnvironment pe;
-	private final Map<String, IMetaEntity> metaEntitiesToProcess = new HashMap<String, IMetaEntity>();
-	private final Map<String, IMetaEntity> metaSuperclassAndEmbeddableToProcess = new HashMap<String, IMetaEntity>();
+	private final Map<String, MetaEntity> metaEntitiesToProcess = new HashMap<String, MetaEntity>();
+	private final Map<String, MetaEntity> metaSuperclassAndEmbeddableToProcess = new HashMap<String, MetaEntity>();
 
 	private static class AccessTypeHolder {
 		public AccessType elementAccessType;
@@ -50,11 +50,11 @@
 		this.pe = pe;
 	}
 
-	public Map<String, IMetaEntity> getMetaEntitiesToProcess() {
+	public Map<String, MetaEntity> getMetaEntitiesToProcess() {
 		return metaEntitiesToProcess;
 	}
 
-	public Map<String, IMetaEntity> getMetaSuperclassAndEmbeddableToProcess() {
+	public Map<String, MetaEntity> getMetaSuperclassAndEmbeddableToProcess() {
 		return metaSuperclassAndEmbeddableToProcess;
 	}
 
@@ -98,7 +98,7 @@
 			return;
 		}
 
-		ClassWriter.writeFile( new MetaEntity( pe, element, this, defaultAccessTypeForHierarchy ), pe, this );
+		ClassWriter.writeFile( new AnnotationMetaEntity( pe, element, this, defaultAccessTypeForHierarchy ), pe, this );
 		elementsAlreadyProcessed.add( element.getQualifiedName().toString() );
 	}
 }

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,31 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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;
-
-/**
- * @author Hardy Ferentschik
- */
-public interface IMetaAttribute {
-    String getDeclarationString();
-
-    String getMetaType();
-
-    String getPropertyName();
-
-   String getTypeDeclaration(); 
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,26 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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;
-
-import org.hibernate.jpamodelgen.IMetaAttribute;
-
-/**
- * @author Hardy Ferentschik
- */
-public interface IMetaCollection extends IMetaAttribute {
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,45 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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;
-
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import java.util.List;
-
-/**
- * @author Hardy Ferentschik
- */
-public interface IMetaEntity extends ImportContext {
-    String getSimpleName();
-
-    String getQualifiedName();
-
-    String getPackageName();
-
-    List<IMetaAttribute> getMembers();
-
-    String generateImports();
-
-    String importType(String fqcn);
-
-    String staticImport(String fqcn, String member);
-
-    String importType(Name qualifiedName);
-
-	TypeElement getTypeElement();
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,24 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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;
-
-/**
- * @author Hardy Ferentschik
- */
-public interface IMetaSingleAttribute extends IMetaAttribute {
-}

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -48,7 +48,7 @@
 
 import org.xml.sax.SAXException;
 
-import org.hibernate.jpamodelgen.annotation.MetaEntity;
+import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity;
 import org.hibernate.jpamodelgen.xml.XmlMetaEntity;
 import org.hibernate.jpamodelgen.xml.jaxb.Entity;
 import org.hibernate.jpamodelgen.xml.jaxb.EntityMappings;
@@ -125,7 +125,7 @@
 	}
 
 	private void createMetaModelClasses() {
-		for ( IMetaEntity entity : context.getMetaEntitiesToProcess().values() ) {
+		for ( MetaEntity entity : context.getMetaEntitiesToProcess().values() ) {
 			processingEnv.getMessager()
 					.printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + entity );
 			ClassWriter.writeFile( entity, processingEnv, context );
@@ -136,7 +136,7 @@
 			context.getMetaSuperclassAndEmbeddableToProcess().remove( className );
 		}
 
-		for ( IMetaEntity entity : context.getMetaSuperclassAndEmbeddableToProcess().values() ) {
+		for ( MetaEntity entity : context.getMetaSuperclassAndEmbeddableToProcess().values() ) {
 			processingEnv.getMessager()
 					.printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + entity );
 			ClassWriter.writeFile( entity, processingEnv, context );
@@ -325,13 +325,13 @@
 
 			if ( element.getKind() == ElementKind.CLASS ) {
 				if ( annotationType.equals( ENTITY_ANN ) ) {
-					MetaEntity metaEntity = new MetaEntity( processingEnv, ( TypeElement ) element, context );
+					AnnotationMetaEntity metaEntity = new AnnotationMetaEntity( processingEnv, ( TypeElement ) element, context );
 					// TODO instead of just adding the entity we have to do some merging.
 					context.getMetaEntitiesToProcess().put( metaEntity.getQualifiedName(), metaEntity );
 				}
 				else if ( annotationType.equals( MAPPED_SUPERCLASS_ANN )
 						|| annotationType.equals( EMBEDDABLE_ANN ) ) {
-					MetaEntity metaEntity = new MetaEntity( processingEnv, ( TypeElement ) element, context );
+					AnnotationMetaEntity metaEntity = new AnnotationMetaEntity( processingEnv, ( TypeElement ) element, context );
 
 					// TODO instead of just adding the entity we have to do some merging.
 					context.getMetaSuperclassAndEmbeddableToProcess().put( metaEntity.getQualifiedName(), metaEntity );

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,31 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface MetaAttribute {
+    String getDeclarationString();
+
+    String getMetaType();
+
+    String getPropertyName();
+
+   String getTypeDeclaration(); 
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,26 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+import org.hibernate.jpamodelgen.MetaAttribute;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface MetaCollection extends MetaAttribute {
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,45 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import java.util.List;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface MetaEntity extends ImportContext {
+    String getSimpleName();
+
+    String getQualifiedName();
+
+    String getPackageName();
+
+    List<MetaAttribute> getMembers();
+
+    String generateImports();
+
+    String importType(String fqcn);
+
+    String staticImport(String fqcn, String member);
+
+    String importType(Name qualifiedName);
+
+	TypeElement getTypeElement();
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,24 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface MetaSingleAttribute extends MetaAttribute {
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,74 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.annotation;
+
+import org.hibernate.jpamodelgen.MetaAttribute;
+
+import java.beans.Introspector;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+
+/**
+ *
+ * @author Max Andersen
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public abstract class AnnotationMetaAttribute implements MetaAttribute {
+
+	final protected Element element;
+	final protected AnnotationMetaEntity parent;
+	final protected ProcessingEnvironment pe;
+	private final String type;
+
+	public AnnotationMetaAttribute(AnnotationMetaEntity parent, Element element, String type) {
+		this.element = element;
+		this.parent = parent;
+		this.type = type;
+		this.pe = parent.pe;
+	}
+
+	public String getDeclarationString() {
+		return "public static volatile " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";  
+	}
+
+	public String getPropertyName() {
+		if(element.getKind()==ElementKind.FIELD) {
+			return element.getSimpleName().toString();
+		} else if (element.getKind()==ElementKind.METHOD) {
+			
+			String name = element.getSimpleName().toString();
+			if(name.startsWith("get")) {
+				return pe.getElementUtils().getName(Introspector.decapitalize(name.substring("get".length()))).toString();
+			} else if(name.startsWith("is")) {
+				return (pe.getElementUtils().getName(Introspector.decapitalize(name.substring("is".length())))).toString();
+			}
+			return pe.getElementUtils().getName(Introspector.decapitalize(name)).toString();
+		} else {
+			return pe.getElementUtils().getName(element.getSimpleName() + "/* " + element.getKind() + " */").toString();
+		}
+	}
+
+	abstract public String getMetaType();
+
+	public String getTypeDeclaration() {
+		return type;		
+	}
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,46 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.annotation;
+
+import org.hibernate.jpamodelgen.MetaCollection;
+
+import javax.lang.model.element.Element;
+
+/**
+ *
+ * @author Max Andersen
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public class AnnotationMetaCollection extends AnnotationMetaAttribute implements MetaCollection {
+
+	private String collectionType; 
+	
+
+	public AnnotationMetaCollection(AnnotationMetaEntity parent, Element element, String collectionType, String elementType) {
+		super(parent, element, elementType);
+		this.collectionType = collectionType;		
+	}
+
+	@Override
+	public String getMetaType() {		
+		return collectionType;
+	}
+
+	
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,433 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.annotation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.PrimitiveType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.SimpleTypeVisitor6;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Id;
+import javax.persistence.AccessType;
+import javax.persistence.Entity;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import javax.persistence.Embedded;
+import javax.persistence.Embeddable;
+import javax.persistence.Access;
+import javax.persistence.ElementCollection;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.Diagnostic;
+
+import org.hibernate.jpamodelgen.MetaEntity;
+import org.hibernate.jpamodelgen.MetaAttribute;
+import org.hibernate.jpamodelgen.ImportContext;
+import org.hibernate.jpamodelgen.ImportContextImpl;
+import org.hibernate.jpamodelgen.TypeUtils;
+import org.hibernate.jpamodelgen.Context;
+
+/**
+ *
+ * @author Max Andersen
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public class AnnotationMetaEntity implements MetaEntity {
+
+	final TypeElement element;
+	final protected ProcessingEnvironment pe;
+
+	final ImportContext importContext;
+	private Context context;
+	//used to propagate the access type of the root entity over to subclasses, superclasses and embeddable
+	private AccessType defaultAccessTypeForHierarchy;
+	private AccessType defaultAccessTypeForElement;
+
+	public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element, Context context) {
+		this.element = element;
+		this.pe = pe;
+		importContext = new ImportContextImpl( getPackageName() );
+		this.context = context;
+	}
+
+	public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element, Context context, AccessType accessType) {
+		this(pe, element, context);
+		this.defaultAccessTypeForHierarchy = accessType;
+	}
+
+	public String getSimpleName() {
+		return element.getSimpleName().toString();
+	}
+
+	public Element getOriginalElement() {
+		return element;
+	}
+
+	public String getQualifiedName() {
+		return element.getQualifiedName().toString();
+	}
+
+	public String getPackageName() {
+		PackageElement packageOf = pe.getElementUtils().getPackageOf( element );
+		return pe.getElementUtils().getName( packageOf.getQualifiedName() ).toString();
+	}
+
+	public List<MetaAttribute> getMembers() {
+		List<MetaAttribute> membersFound = new ArrayList<MetaAttribute>();
+		final AccessType elementAccessType = getAccessTypeForElement();
+
+		List<? extends Element> fieldsOfClass = ElementFilter.fieldsIn( element.getEnclosedElements() );
+		addPersistentMembers( membersFound, elementAccessType, fieldsOfClass, AccessType.FIELD );
+
+		List<? extends Element> methodsOfClass = ElementFilter.methodsIn( element.getEnclosedElements() );
+		addPersistentMembers( membersFound, elementAccessType, methodsOfClass, AccessType.PROPERTY );
+
+		//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 ) {
+				//FIXME use the class defalut access type
+				context.processElement( superclass, defaultAccessTypeForHierarchy );
+			}
+		}
+
+		//this is valid to not have properties (ie subentities)
+//		if ( membersFound.size() == 0 ) {
+//			pe.getMessager().printMessage( Kind.WARNING, "No properties found on " + element, element );
+//		}
+		return membersFound;
+	}
+
+	private void addPersistentMembers(
+			List<MetaAttribute> membersFound,
+			AccessType elementAccessType,
+			List<? extends Element> membersOfClass,
+			AccessType membersKind) {
+		pe.getMessager()
+					.printMessage( Kind.NOTE, "Scanning " + membersOfClass.size() + " " + membersKind + " for " + element.toString() );
+		AccessType explicitAccessType;
+		if (elementAccessType == membersKind) {
+			//all membersKind considered
+			explicitAccessType = null;
+		}
+		else {
+			//use membersKind only if marked with @Access(membersKind)
+			explicitAccessType = membersKind;
+		}
+		for ( Element memberOfClass : membersOfClass ) {
+
+			AnnotationMetaAttribute result = memberOfClass.asType().accept( new TypeVisitor( this, explicitAccessType ),
+					memberOfClass
+			);
+			if ( result != null ) {
+				membersFound.add( result );
+			}
+//EBE not sure why?
+//			else {
+//				pe.getMessager().printMessage( Kind.WARNING, "Could not find valid info for JPA property", mymember );
+//			}
+		}
+	}
+
+	private AccessType getAccessTypeForElement() {
+
+		//get local strategy
+		AccessType accessType = getAccessTypeForClass(element);
+		if (accessType == null) {
+			accessType = this.defaultAccessTypeForHierarchy;
+		}
+		if (accessType == null) {
+			//we dont' know
+			//if an enity go up
+			//
+			//superclasses alre always treated after their entities
+			//and their access type are discovered
+			//FIXME is it really true if only the superclass is changed
+			TypeElement superClass = element;
+			do {
+				superClass = TypeUtils.getSuperclass( superClass );
+				if (superClass != null) {
+					if ( superClass.getAnnotation( Entity.class ) != null
+							|| superClass.getAnnotation( MappedSuperclass.class ) != null ) {
+						//FIXME make it work for XML
+						AccessType superClassAccessType = getAccessTypeForClass(superClass);
+						//we've reach the root entity and resolved Ids
+						if ( superClassAccessType != null && defaultAccessTypeForHierarchy != null) {
+							break; //we've found it
+						}
+					}
+					else {
+						break; //neither @Entity nor @MappedSuperclass
+					}
+				}
+			}
+			while ( superClass != null );
+		}
+
+		if ( accessType == null ) {
+			accessType = AccessType.PROPERTY; //default to property
+			this.defaultAccessTypeForElement = accessType;
+		}
+		//this is a subclass so caching is OK
+		//this.defaultAccessTypeForHierarchy = accessType;
+		context.addAccessType( this.element, accessType );
+		this.defaultAccessTypeForElement = accessType;
+		return accessType;
+	}
+
+	private AccessType getAccessTypeForClass(TypeElement searchedElement) {
+		pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + searchedElement );
+		AccessType accessType = context.getAccessType( searchedElement );
+
+		if (defaultAccessTypeForHierarchy == null) {
+			this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
+		}
+		if ( accessType != null ) {
+			pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedElement + ":" + accessType );
+			return accessType;
+		}
+
+		/**
+		 * when forcing access type, we can only override the defaultAccessTypeForHierarchy
+		 * if we are the entity root (identified by having @Id or @EmbeddedId
+		 */
+		final Access accessAnn = searchedElement.getAnnotation( Access.class );
+		AccessType forcedAccessType = accessAnn != null ? accessAnn.value() : null;
+		if ( forcedAccessType != null) {
+			pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + forcedAccessType );
+			context.addAccessType( searchedElement, forcedAccessType );
+		}
+
+		//continue nevertheless to check if we are root and if defaultAccessTypeForHierarchy
+		//should be overridden
+		if ( forcedAccessType == null || defaultAccessTypeForHierarchy == null) {
+			List<? extends Element> myMembers = searchedElement.getEnclosedElements();
+			for ( Element subElement : myMembers ) {
+				List<? extends AnnotationMirror> entityAnnotations =
+						pe.getElementUtils().getAllAnnotationMirrors( subElement );
+
+				for ( Object entityAnnotation : entityAnnotations ) {
+					AnnotationMirror annotationMirror = ( AnnotationMirror ) entityAnnotation;
+
+					final String annotationType = annotationMirror.getAnnotationType().toString();
+
+					//FIXME consider XML
+					if ( annotationType.equals( Id.class.getName() )
+							|| annotationType.equals( EmbeddedId.class.getName() ) ) {
+						pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found id on" + searchedElement );
+						final ElementKind kind = subElement.getKind();
+						if ( kind == ElementKind.FIELD || kind == ElementKind.METHOD ) {
+							accessType = kind == ElementKind.FIELD ? AccessType.FIELD : AccessType.PROPERTY;
+							//FIXME enlever in niveau
+							if (defaultAccessTypeForHierarchy == null) {
+								this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
+								//we've discovered the class hierarchy, let's cache it
+								if ( defaultAccessTypeForHierarchy == null ) {
+									this.defaultAccessTypeForHierarchy = accessType;
+									context.addAccessTypeForHierarchy( searchedElement, defaultAccessTypeForHierarchy );
+									//FIXME should we add
+									//context.addAccessTypeForHierarchy( element, defaultAccessTypeForHierarchy );
+								}
+							}
+							if ( forcedAccessType == null) {
+								context.addAccessType( searchedElement, accessType );
+								pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + accessType );
+								return accessType;
+							}
+							else {
+								return forcedAccessType;
+							}
+						}
+					}
+				}
+			}
+		}
+		return forcedAccessType;
+	}
+
+	@Override
+	public String toString() {
+		final StringBuilder sb = new StringBuilder();
+		sb.append( "MetaEntity" );
+		sb.append( "{element=" ).append( element );
+		sb.append( '}' );
+		return sb.toString();
+	}
+
+	static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+
+	static {
+		COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" );
+		COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttribute" );
+		COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttribute" );
+		COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttribute" );
+	}
+
+	class TypeVisitor extends SimpleTypeVisitor6<AnnotationMetaAttribute, Element> {
+
+		AnnotationMetaEntity parent;
+		//if null, process all members as implicit
+		//if not null, only process members marked as @Access(explicitAccessType)
+		private AccessType explicitAccessType;
+
+		TypeVisitor(AnnotationMetaEntity parent, AccessType explicitAccessType) {
+			this.parent = parent;
+			this.explicitAccessType = explicitAccessType;
+		}
+
+		@Override
+		protected AnnotationMetaAttribute defaultAction(TypeMirror e, Element p) {
+			return super.defaultAction( e, p );
+		}
+
+		@Override
+		public AnnotationMetaAttribute visitPrimitive(PrimitiveType t, Element element) {
+			if ( isPersistent( element ) ) {
+				return new AnnotationMetaSingleAttribute( parent, element, TypeUtils.toTypeString( t ) );
+			}
+			else {
+				return null;
+			}
+		}
+
+		private boolean isPersistent(Element element) {
+			//FIXME consider XML
+			boolean correctAccessType = false;
+			if (this.explicitAccessType == null) {
+				correctAccessType = true;
+			}
+			else {
+				final Access accessAnn = element.getAnnotation( Access.class );
+				if ( accessAnn != null && explicitAccessType.equals( accessAnn.value() ) ) {
+					correctAccessType = true;
+				}
+			}
+			return correctAccessType
+					&& element.getAnnotation( Transient.class ) == null
+					&& !element.getModifiers().contains( Modifier.TRANSIENT )
+					&& !element.getModifiers().contains( Modifier.STATIC );
+
+		}
+
+
+		@Override
+		public AnnotationMetaAttribute visitDeclared(DeclaredType t, Element element) {
+			//FIXME consider XML
+			if ( isPersistent( element ) ) {
+				TypeElement returnedElement = ( TypeElement ) pe.getTypeUtils().asElement( t );
+				String collection = COLLECTIONS.get( returnedElement.getQualifiedName().toString() ); // WARNING: .toString() is necessary here since Name equals does not compare to String
+
+				if ( collection != null ) {
+					//collection of element
+					if ( element.getAnnotation( ElementCollection.class ) != null ) {
+						final TypeMirror collectionType = t.getTypeArguments().get( 0 );
+						final TypeElement collectionElement = ( TypeElement ) pe.getTypeUtils().asElement( collectionType );
+						this.parent.context.processElement( collectionElement,
+								this.parent.defaultAccessTypeForElement );
+					}
+					if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) ) {
+						return new AnnotationMetaMap( parent, element, collection, getKeyType( t ), getElementType( t ) );
+					}
+					else {
+						return new AnnotationMetaCollection( parent, element, collection, getElementType( t ) );
+					}
+				}
+				else {
+					//FIXME Consider XML
+					if ( element.getAnnotation( Embedded.class ) != null
+							|| returnedElement.getAnnotation( Embeddable.class ) != null ) {
+						this.parent.context.processElement( returnedElement, 
+								this.parent.defaultAccessTypeForElement );
+					}
+					return new AnnotationMetaSingleAttribute( parent, element, returnedElement.getQualifiedName().toString() );
+				}
+			}
+			else {
+				return null;
+			}
+		}
+
+
+		@Override
+		public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element p) {
+			String string = p.getSimpleName().toString();
+
+			// TODO: implement proper property get/is/boolean detection
+			if ( string.startsWith( "get" ) || string.startsWith( "is" ) ) {
+				TypeMirror returnType = t.getReturnType();
+
+				return returnType.accept( this, p );
+			}
+			else {
+				return null;
+			}
+		}
+	}
+
+	public String generateImports() {
+		return importContext.generateImports();
+	}
+
+	public String importType(String fqcn) {
+		return importContext.importType( fqcn );
+	}
+
+	public String staticImport(String fqcn, String member) {
+		return importContext.staticImport( fqcn, member );
+	}
+
+	public String importType(Name qualifiedName) {
+		return importType( qualifiedName.toString() );
+	}
+
+	public TypeElement getTypeElement() {
+		return element;
+	}
+
+	private String getKeyType(DeclaredType t) {
+		return t.getTypeArguments().get( 0 ).toString();
+	}
+
+
+	private String getElementType(DeclaredType declaredType) {
+		if ( declaredType.getTypeArguments().size() == 1 ) {
+			return declaredType.getTypeArguments().get( 0 ).toString();
+		}
+		else {
+			return declaredType.getTypeArguments().get( 1 ).toString();
+		}
+	}
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,42 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.annotation;
+
+import javax.lang.model.element.Element;
+
+/**
+ *
+ * @author Max Andersen
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public class AnnotationMetaMap extends AnnotationMetaCollection {
+
+	private final String keyType;
+
+	public AnnotationMetaMap(AnnotationMetaEntity parent, Element element, String collectionType,
+			String keyType, String elementType) {
+		super(parent, element, collectionType, elementType);
+		this.keyType = keyType;		
+	}
+
+	public String getDeclarationString() {
+		return "public static volatile " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";  
+	}
+
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java (from rev 17898, jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java)
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java	                        (rev 0)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,41 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.annotation;
+
+import org.hibernate.jpamodelgen.MetaSingleAttribute;
+
+import javax.lang.model.element.Element;
+
+/**
+ *
+ * @author Max Andersen
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public class AnnotationMetaSingleAttribute extends AnnotationMetaAttribute implements MetaSingleAttribute {
+
+	public AnnotationMetaSingleAttribute(AnnotationMetaEntity parent, Element element, String type) {
+		super(parent, element, type);
+	}
+
+	@Override
+	public String getMetaType() {
+		return "javax.persistence.metamodel.SingularAttribute";
+	}
+
+}


Property changes on: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,74 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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.annotation;
-
-import org.hibernate.jpamodelgen.IMetaAttribute;
-
-import java.beans.Introspector;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-
-/**
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public abstract class MetaAttribute implements IMetaAttribute {
-
-	final protected Element element;
-	final protected MetaEntity parent;
-	final protected ProcessingEnvironment pe;
-	private final String type;
-
-	public MetaAttribute(MetaEntity parent, Element element, String type) {
-		this.element = element;
-		this.parent = parent;
-		this.type = type;
-		this.pe = parent.pe;
-	}
-
-	public String getDeclarationString() {
-		return "public static volatile " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";  
-	}
-
-	public String getPropertyName() {
-		if(element.getKind()==ElementKind.FIELD) {
-			return element.getSimpleName().toString();
-		} else if (element.getKind()==ElementKind.METHOD) {
-			
-			String name = element.getSimpleName().toString();
-			if(name.startsWith("get")) {
-				return pe.getElementUtils().getName(Introspector.decapitalize(name.substring("get".length()))).toString();
-			} else if(name.startsWith("is")) {
-				return (pe.getElementUtils().getName(Introspector.decapitalize(name.substring("is".length())))).toString();
-			}
-			return pe.getElementUtils().getName(Introspector.decapitalize(name)).toString();
-		} else {
-			return pe.getElementUtils().getName(element.getSimpleName() + "/* " + element.getKind() + " */").toString();
-		}
-	}
-
-	abstract public String getMetaType();
-
-	public String getTypeDeclaration() {
-		return type;		
-	}
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,46 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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.annotation;
-
-import org.hibernate.jpamodelgen.IMetaCollection;
-
-import javax.lang.model.element.Element;
-
-/**
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class MetaCollection extends MetaAttribute implements IMetaCollection {
-
-	private String collectionType; 
-	
-
-	public MetaCollection(MetaEntity parent, Element element, String collectionType, String elementType) {
-		super(parent, element, elementType);
-		this.collectionType = collectionType;		
-	}
-
-	@Override
-	public String getMetaType() {		
-		return collectionType;
-	}
-
-	
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,433 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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.annotation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.ExecutableType;
-import javax.lang.model.type.PrimitiveType;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.SimpleTypeVisitor6;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Id;
-import javax.persistence.AccessType;
-import javax.persistence.Entity;
-import javax.persistence.MappedSuperclass;
-import javax.persistence.Transient;
-import javax.persistence.Embedded;
-import javax.persistence.Embeddable;
-import javax.persistence.Access;
-import javax.persistence.ElementCollection;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.Diagnostic;
-
-import org.hibernate.jpamodelgen.IMetaEntity;
-import org.hibernate.jpamodelgen.IMetaAttribute;
-import org.hibernate.jpamodelgen.ImportContext;
-import org.hibernate.jpamodelgen.ImportContextImpl;
-import org.hibernate.jpamodelgen.TypeUtils;
-import org.hibernate.jpamodelgen.Context;
-
-/**
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class MetaEntity implements IMetaEntity {
-
-	final TypeElement element;
-	final protected ProcessingEnvironment pe;
-
-	final ImportContext importContext;
-	private Context context;
-	//used to propagate the access type of the root entity over to subclasses, superclasses and embeddable
-	private AccessType defaultAccessTypeForHierarchy;
-	private AccessType defaultAccessTypeForElement;
-
-	public MetaEntity(ProcessingEnvironment pe, TypeElement element, Context context) {
-		this.element = element;
-		this.pe = pe;
-		importContext = new ImportContextImpl( getPackageName() );
-		this.context = context;
-	}
-
-	public MetaEntity(ProcessingEnvironment pe, TypeElement element, Context context, AccessType accessType) {
-		this(pe, element, context);
-		this.defaultAccessTypeForHierarchy = accessType;
-	}
-
-	public String getSimpleName() {
-		return element.getSimpleName().toString();
-	}
-
-	public Element getOriginalElement() {
-		return element;
-	}
-
-	public String getQualifiedName() {
-		return element.getQualifiedName().toString();
-	}
-
-	public String getPackageName() {
-		PackageElement packageOf = pe.getElementUtils().getPackageOf( element );
-		return pe.getElementUtils().getName( packageOf.getQualifiedName() ).toString();
-	}
-
-	public List<IMetaAttribute> getMembers() {
-		List<IMetaAttribute> membersFound = new ArrayList<IMetaAttribute>();
-		final AccessType elementAccessType = getAccessTypeForElement();
-
-		List<? extends Element> fieldsOfClass = ElementFilter.fieldsIn( element.getEnclosedElements() );
-		addPersistentMembers( membersFound, elementAccessType, fieldsOfClass, AccessType.FIELD );
-
-		List<? extends Element> methodsOfClass = ElementFilter.methodsIn( element.getEnclosedElements() );
-		addPersistentMembers( membersFound, elementAccessType, methodsOfClass, AccessType.PROPERTY );
-
-		//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 ) {
-				//FIXME use the class defalut access type
-				context.processElement( superclass, defaultAccessTypeForHierarchy );
-			}
-		}
-
-		//this is valid to not have properties (ie subentities)
-//		if ( membersFound.size() == 0 ) {
-//			pe.getMessager().printMessage( Kind.WARNING, "No properties found on " + element, element );
-//		}
-		return membersFound;
-	}
-
-	private void addPersistentMembers(
-			List<IMetaAttribute> membersFound,
-			AccessType elementAccessType,
-			List<? extends Element> membersOfClass,
-			AccessType membersKind) {
-		pe.getMessager()
-					.printMessage( Kind.NOTE, "Scanning " + membersOfClass.size() + " " + membersKind + " for " + element.toString() );
-		AccessType explicitAccessType;
-		if (elementAccessType == membersKind) {
-			//all membersKind considered
-			explicitAccessType = null;
-		}
-		else {
-			//use membersKind only if marked with @Access(membersKind)
-			explicitAccessType = membersKind;
-		}
-		for ( Element memberOfClass : membersOfClass ) {
-
-			MetaAttribute result = memberOfClass.asType().accept( new TypeVisitor( this, explicitAccessType ),
-					memberOfClass
-			);
-			if ( result != null ) {
-				membersFound.add( result );
-			}
-//EBE not sure why?
-//			else {
-//				pe.getMessager().printMessage( Kind.WARNING, "Could not find valid info for JPA property", mymember );
-//			}
-		}
-	}
-
-	private AccessType getAccessTypeForElement() {
-
-		//get local strategy
-		AccessType accessType = getAccessTypeForClass(element);
-		if (accessType == null) {
-			accessType = this.defaultAccessTypeForHierarchy;
-		}
-		if (accessType == null) {
-			//we dont' know
-			//if an enity go up
-			//
-			//superclasses alre always treated after their entities
-			//and their access type are discovered
-			//FIXME is it really true if only the superclass is changed
-			TypeElement superClass = element;
-			do {
-				superClass = TypeUtils.getSuperclass( superClass );
-				if (superClass != null) {
-					if ( superClass.getAnnotation( Entity.class ) != null
-							|| superClass.getAnnotation( MappedSuperclass.class ) != null ) {
-						//FIXME make it work for XML
-						AccessType superClassAccessType = getAccessTypeForClass(superClass);
-						//we've reach the root entity and resolved Ids
-						if ( superClassAccessType != null && defaultAccessTypeForHierarchy != null) {
-							break; //we've found it
-						}
-					}
-					else {
-						break; //neither @Entity nor @MappedSuperclass
-					}
-				}
-			}
-			while ( superClass != null );
-		}
-
-		if ( accessType == null ) {
-			accessType = AccessType.PROPERTY; //default to property
-			this.defaultAccessTypeForElement = accessType;
-		}
-		//this is a subclass so caching is OK
-		//this.defaultAccessTypeForHierarchy = accessType;
-		context.addAccessType( this.element, accessType );
-		this.defaultAccessTypeForElement = accessType;
-		return accessType;
-	}
-
-	private AccessType getAccessTypeForClass(TypeElement searchedElement) {
-		pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "check class" + searchedElement );
-		AccessType accessType = context.getAccessType( searchedElement );
-
-		if (defaultAccessTypeForHierarchy == null) {
-			this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
-		}
-		if ( accessType != null ) {
-			pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found in cache" + searchedElement + ":" + accessType );
-			return accessType;
-		}
-
-		/**
-		 * when forcing access type, we can only override the defaultAccessTypeForHierarchy
-		 * if we are the entity root (identified by having @Id or @EmbeddedId
-		 */
-		final Access accessAnn = searchedElement.getAnnotation( Access.class );
-		AccessType forcedAccessType = accessAnn != null ? accessAnn.value() : null;
-		if ( forcedAccessType != null) {
-			pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + forcedAccessType );
-			context.addAccessType( searchedElement, forcedAccessType );
-		}
-
-		//continue nevertheless to check if we are root and if defaultAccessTypeForHierarchy
-		//should be overridden
-		if ( forcedAccessType == null || defaultAccessTypeForHierarchy == null) {
-			List<? extends Element> myMembers = searchedElement.getEnclosedElements();
-			for ( Element subElement : myMembers ) {
-				List<? extends AnnotationMirror> entityAnnotations =
-						pe.getElementUtils().getAllAnnotationMirrors( subElement );
-
-				for ( Object entityAnnotation : entityAnnotations ) {
-					AnnotationMirror annotationMirror = ( AnnotationMirror ) entityAnnotation;
-
-					final String annotationType = annotationMirror.getAnnotationType().toString();
-
-					//FIXME consider XML
-					if ( annotationType.equals( Id.class.getName() )
-							|| annotationType.equals( EmbeddedId.class.getName() ) ) {
-						pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "Found id on" + searchedElement );
-						final ElementKind kind = subElement.getKind();
-						if ( kind == ElementKind.FIELD || kind == ElementKind.METHOD ) {
-							accessType = kind == ElementKind.FIELD ? AccessType.FIELD : AccessType.PROPERTY;
-							//FIXME enlever in niveau
-							if (defaultAccessTypeForHierarchy == null) {
-								this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
-								//we've discovered the class hierarchy, let's cache it
-								if ( defaultAccessTypeForHierarchy == null ) {
-									this.defaultAccessTypeForHierarchy = accessType;
-									context.addAccessTypeForHierarchy( searchedElement, defaultAccessTypeForHierarchy );
-									//FIXME should we add
-									//context.addAccessTypeForHierarchy( element, defaultAccessTypeForHierarchy );
-								}
-							}
-							if ( forcedAccessType == null) {
-								context.addAccessType( searchedElement, accessType );
-								pe.getMessager().printMessage( Diagnostic.Kind.NOTE, "access type " + searchedElement + ":" + accessType );
-								return accessType;
-							}
-							else {
-								return forcedAccessType;
-							}
-						}
-					}
-				}
-			}
-		}
-		return forcedAccessType;
-	}
-
-	@Override
-	public String toString() {
-		final StringBuilder sb = new StringBuilder();
-		sb.append( "MetaEntity" );
-		sb.append( "{element=" ).append( element );
-		sb.append( '}' );
-		return sb.toString();
-	}
-
-	static Map<String, String> COLLECTIONS = new HashMap<String, String>();
-
-	static {
-		COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" );
-		COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttribute" );
-		COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttribute" );
-		COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttribute" );
-	}
-
-	class TypeVisitor extends SimpleTypeVisitor6<MetaAttribute, Element> {
-
-		MetaEntity parent;
-		//if null, process all members as implicit
-		//if not null, only process members marked as @Access(explicitAccessType)
-		private AccessType explicitAccessType;
-
-		TypeVisitor(MetaEntity parent, AccessType explicitAccessType) {
-			this.parent = parent;
-			this.explicitAccessType = explicitAccessType;
-		}
-
-		@Override
-		protected MetaAttribute defaultAction(TypeMirror e, Element p) {
-			return super.defaultAction( e, p );
-		}
-
-		@Override
-		public MetaAttribute visitPrimitive(PrimitiveType t, Element element) {
-			if ( isPersistent( element ) ) {
-				return new MetaSingleAttribute( parent, element, TypeUtils.toTypeString( t ) );
-			}
-			else {
-				return null;
-			}
-		}
-
-		private boolean isPersistent(Element element) {
-			//FIXME consider XML
-			boolean correctAccessType = false;
-			if (this.explicitAccessType == null) {
-				correctAccessType = true;
-			}
-			else {
-				final Access accessAnn = element.getAnnotation( Access.class );
-				if ( accessAnn != null && explicitAccessType.equals( accessAnn.value() ) ) {
-					correctAccessType = true;
-				}
-			}
-			return correctAccessType
-					&& element.getAnnotation( Transient.class ) == null
-					&& !element.getModifiers().contains( Modifier.TRANSIENT )
-					&& !element.getModifiers().contains( Modifier.STATIC );
-
-		}
-
-
-		@Override
-		public MetaAttribute visitDeclared(DeclaredType t, Element element) {
-			//FIXME consider XML
-			if ( isPersistent( element ) ) {
-				TypeElement returnedElement = ( TypeElement ) pe.getTypeUtils().asElement( t );
-				String collection = COLLECTIONS.get( returnedElement.getQualifiedName().toString() ); // WARNING: .toString() is necessary here since Name equals does not compare to String
-
-				if ( collection != null ) {
-					//collection of element
-					if ( element.getAnnotation( ElementCollection.class ) != null ) {
-						final TypeMirror collectionType = t.getTypeArguments().get( 0 );
-						final TypeElement collectionElement = ( TypeElement ) pe.getTypeUtils().asElement( collectionType );
-						this.parent.context.processElement( collectionElement,
-								this.parent.defaultAccessTypeForElement );
-					}
-					if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) ) {
-						return new MetaMap( parent, element, collection, getKeyType( t ), getElementType( t ) );
-					}
-					else {
-						return new MetaCollection( parent, element, collection, getElementType( t ) );
-					}
-				}
-				else {
-					//FIXME Consider XML
-					if ( element.getAnnotation( Embedded.class ) != null
-							|| returnedElement.getAnnotation( Embeddable.class ) != null ) {
-						this.parent.context.processElement( returnedElement, 
-								this.parent.defaultAccessTypeForElement );
-					}
-					return new MetaSingleAttribute( parent, element, returnedElement.getQualifiedName().toString() );
-				}
-			}
-			else {
-				return null;
-			}
-		}
-
-
-		@Override
-		public MetaAttribute visitExecutable(ExecutableType t, Element p) {
-			String string = p.getSimpleName().toString();
-
-			// TODO: implement proper property get/is/boolean detection
-			if ( string.startsWith( "get" ) || string.startsWith( "is" ) ) {
-				TypeMirror returnType = t.getReturnType();
-
-				return returnType.accept( this, p );
-			}
-			else {
-				return null;
-			}
-		}
-	}
-
-	public String generateImports() {
-		return importContext.generateImports();
-	}
-
-	public String importType(String fqcn) {
-		return importContext.importType( fqcn );
-	}
-
-	public String staticImport(String fqcn, String member) {
-		return importContext.staticImport( fqcn, member );
-	}
-
-	public String importType(Name qualifiedName) {
-		return importType( qualifiedName.toString() );
-	}
-
-	public TypeElement getTypeElement() {
-		return element;
-	}
-
-	private String getKeyType(DeclaredType t) {
-		return t.getTypeArguments().get( 0 ).toString();
-	}
-
-
-	private String getElementType(DeclaredType declaredType) {
-		if ( declaredType.getTypeArguments().size() == 1 ) {
-			return declaredType.getTypeArguments().get( 0 ).toString();
-		}
-		else {
-			return declaredType.getTypeArguments().get( 1 ).toString();
-		}
-	}
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,42 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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.annotation;
-
-import javax.lang.model.element.Element;
-
-/**
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class MetaMap extends MetaCollection {
-
-	private final String keyType;
-
-	public MetaMap(MetaEntity parent, Element element, String collectionType,
-			String keyType, String elementType) {
-		super(parent, element, collectionType, elementType);
-		this.keyType = keyType;		
-	}
-	
-	public String getDeclarationString() {
-		return "public static volatile " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";  
-	}
-
-}

Deleted: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,41 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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.annotation;
-
-import org.hibernate.jpamodelgen.IMetaSingleAttribute;
-
-import javax.lang.model.element.Element;
-
-/**
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class MetaSingleAttribute extends MetaAttribute implements IMetaSingleAttribute {
-
-	public MetaSingleAttribute(MetaEntity parent, Element element, String type) {
-		super(parent, element, type);
-	}
-
-	@Override
-	public String getMetaType() {
-		return "javax.persistence.metamodel.SingularAttribute";
-	}
-
-}

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -18,12 +18,12 @@
 
 package org.hibernate.jpamodelgen.xml;
 
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaAttribute;
 
 /**
  * @author Hardy Ferentschik
  */
-public abstract class XmlMetaAttribute implements IMetaAttribute {
+public abstract class XmlMetaAttribute implements MetaAttribute {
 
     private XmlMetaEntity parentEntity;
 

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -17,12 +17,12 @@
 */
 package org.hibernate.jpamodelgen.xml;
 
-import org.hibernate.jpamodelgen.IMetaCollection;
+import org.hibernate.jpamodelgen.MetaCollection;
 
 /**
  * @author Hardy Ferentschik
  */
-public class XmlMetaCollection extends XmlMetaAttribute implements IMetaCollection {
+public class XmlMetaCollection extends XmlMetaAttribute implements MetaCollection {
 
     String collectionType;
 

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -26,9 +26,9 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
 
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaAttribute;
 import org.hibernate.jpamodelgen.ImportContextImpl;
-import org.hibernate.jpamodelgen.IMetaEntity;
+import org.hibernate.jpamodelgen.MetaEntity;
 import org.hibernate.jpamodelgen.ImportContext;
 import org.hibernate.jpamodelgen.xml.jaxb.Attributes;
 import org.hibernate.jpamodelgen.xml.jaxb.Basic;
@@ -45,7 +45,7 @@
 /**
  * @author Hardy Ferentschik
  */
-public class XmlMetaEntity implements IMetaEntity {
+public class XmlMetaEntity implements MetaEntity {
 
 	static Map<String, String> COLLECTIONS = new HashMap<String, String>();
 
@@ -62,7 +62,7 @@
 
 	final private ImportContext importContext;
 
-	final private List<IMetaAttribute> members = new ArrayList<IMetaAttribute>();
+	final private List<MetaAttribute> members = new ArrayList<MetaAttribute>();
 
 	private TypeElement element;
 
@@ -135,7 +135,7 @@
 		return packageName;
 	}
 
-	public List<IMetaAttribute> getMembers() {
+	public List<MetaAttribute> getMembers() {
 		return members;
 	}
 

Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -17,12 +17,12 @@
 */
 package org.hibernate.jpamodelgen.xml;
 
-import org.hibernate.jpamodelgen.IMetaSingleAttribute;
+import org.hibernate.jpamodelgen.MetaSingleAttribute;
 
 /**
  * @author Hardy Ferentschik
  */
-public class XmlMetaSingleAttribute extends XmlMetaAttribute implements IMetaSingleAttribute {
+public class XmlMetaSingleAttribute extends XmlMetaAttribute implements MetaSingleAttribute {
 
     public XmlMetaSingleAttribute(XmlMetaEntity parent, String propertyName, String type) {
         super(parent, propertyName, type);

Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTypeTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTypeTest.java	                        (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTypeTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,93 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AccessTypeTest {
+
+	@Test
+	public void testExcludeTransientFieldAndStatic() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Product_", "nonPersistent" );
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Product_", "nonPersistent2" );
+	}
+
+	@Test
+	public void testDefaultAccessTypeOnEntity() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.User_", "nonPersistent" );
+	}
+
+	@Test
+	public void testDefaultAccessTypeForSubclassOfEntity() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Customer_", "nonPersistent" );
+	}
+
+	@Test
+	public void testDefaultAccessTypeForEmbeddable() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Detail_", "nonPersistent" );
+	}
+
+	@Test
+	public void testInheritedAccessTypeForEmbeddable() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Country_", "nonPersistent" );
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Pet_", "nonPersistent", "Colleciton of membeddable not taken care of" );
+	}
+
+	@Test
+	public void testDefaultAccessTypeForMappedSuperclass() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Detail_", "volume" );
+	}
+
+	@Test
+	public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Exception{
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.LivingBeing_", "nonPersistent", "eplicit access type on mapped superclass" );
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Hominidae_", "nonPersistent", "eplicit access type on entity" );
+		absenceOfField( "org.hibernate.jpamodelgen.test.model.Human_", "nonPersistent", "proper inheritance from root entity access type" );
+	}
+
+	@Test
+	public void testMemberAccessType() throws Exception{
+		presenceOfField( "org.hibernate.jpamodelgen.test.model.Customer_", "goodPayer", "access type overriding" );
+	}
+
+	private void absenceOfField(String className, String fieldName) throws ClassNotFoundException {
+		absenceOfField( className, fieldName, "field should not be persistent" );
+	}
+	private void absenceOfField(String className, String fieldName, String errorString) throws ClassNotFoundException {
+		Assert.assertFalse( isFieldHere(className, fieldName), errorString );
+	}
+
+	private void presenceOfField(String className, String fieldName, String errorString) throws ClassNotFoundException {
+		Assert.assertTrue( isFieldHere(className, fieldName), errorString );
+	}
+
+	private boolean isFieldHere(String className, String fieldName) throws ClassNotFoundException {
+		Class<?> user_ = Class.forName( className );
+		try {
+			user_.getField( fieldName );
+			return true;
+		}
+		catch (NoSuchFieldException e) {
+			return false;
+		}
+	}
+}


Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/AccessTypeTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/InheritanceTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/InheritanceTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/InheritanceTest.java	                        (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/InheritanceTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,45 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.hibernate.jpamodelgen.test.model.Customer_;
+import org.hibernate.jpamodelgen.test.model.User_;
+import org.hibernate.jpamodelgen.test.model.House_;
+import org.hibernate.jpamodelgen.test.model.Building_;
+import org.hibernate.jpamodelgen.test.model.Area_;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class InheritanceTest {
+	@Test
+	public void testSuperEntity() throws Exception {
+		Assert.assertEquals( Customer_.class.getSuperclass(), User_.class,
+				"Entity with super entity should inherit at the metamodel level");
+	}
+
+	@Test
+	public void testMappedSuperclass() throws Exception {
+		Assert.assertEquals( House_.class.getSuperclass(), Building_.class,
+				"Entity with mapped superclass should inherit at the metamodel level");
+		Assert.assertEquals( Building_.class.getSuperclass(), Area_.class,
+				"mapped superclass with mapped superclass should inherit at the metamodel level");
+	}
+}


Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/InheritanceTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/QueryTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest.java	                        (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,166 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Set;
+import javax.persistence.Tuple;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Join;
+import static javax.persistence.criteria.JoinType.INNER;
+import javax.persistence.criteria.ListJoin;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Root;
+
+import org.hibernate.jpamodelgen.test.model.Item;
+import org.hibernate.jpamodelgen.test.model.Item_;
+import org.hibernate.jpamodelgen.test.model.Order;
+import org.hibernate.jpamodelgen.test.model.Order_;
+import org.hibernate.jpamodelgen.test.model.Product;
+import org.hibernate.jpamodelgen.test.model.Product_;
+import org.hibernate.jpamodelgen.test.model.Shop_;
+
+/**
+ * Writing queries involves passing typesafe, statically cached, metamodel
+ * objects to the query builder in order to create the various parts of
+ * the query. The typesafe metamodel objects were validated at init time,
+ * so it is impossible to build invalid queries in the application code.
+ *
+ * @author Max Andersen
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public class QueryTest {
+
+	CriteriaBuilder qb;
+
+	public void test() {
+		CriteriaQuery<Tuple> q = qb.createTupleQuery();
+
+		Root<Order> order = q.from( Order.class );
+		Join<Item, Product> product = order.join( Order_.items )
+				.join( Item_.product );
+
+		Path<BigDecimal> price = product.get( Product_.price );
+		Path<Boolean> filled = order.get( Order_.filled );
+		Path<Date> date = order.get( Order_.date );
+
+		q.select( qb.tuple( order, product ) )
+				.where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) )
+				.orderBy( qb.asc( price ), qb.desc( date ) );
+	}
+
+	public void testUntypesafe() {
+		CriteriaQuery<Tuple> q = qb.createTupleQuery();
+
+		Root<Order> order = q.from( Order.class );
+		Join<Item, Product> product = order.join( "items" )
+				.join( "product" );
+
+		Path<BigDecimal> price = product.get( "price" );
+		Path<Boolean> filled = order.get( "filled" );
+		Path<Date> date = order.get( "date" );
+
+		q.select( qb.tuple( order, product ) )
+				.where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) )
+				.orderBy( qb.asc( price ), qb.desc( date ) );
+	}
+
+	/**
+	 * Navigation by joining
+	 */
+	public void test2() {
+		CriteriaQuery<Product> q = qb.createQuery( Product.class );
+
+		Root<Product> product = q.from( Product.class );
+		Join<Item, Order> order = product.join( Product_.items )
+				.join( Item_.order );
+
+		q.select( product )
+				.where( qb.equal( order.get( Order_.id ), 12345l ) );
+	}
+
+	public void testMap() {
+		CriteriaQuery<Item> q = qb.createQuery( Item.class );
+
+		Root<Item> item = q.from( Item.class );
+		item.join( Item_.namedOrders );
+	}
+
+	/**
+	 * Navigation by compound Path
+	 */
+	public void test3() {
+		CriteriaQuery<Item> q = qb.createQuery( Item.class );
+
+		Root<Item> item = q.from( Item.class );
+		Path<String> shopName = item.get( Item_.order )
+				.get( Order_.shop )
+				.get( Shop_.name );
+		q.select( item )
+				.where( qb.equal( shopName, "amazon.com" ) );
+	}
+
+//	public void test4() {
+//		CriteriaQuery q = qb.create();
+//
+//		Root<Order> order = q.from(Order.class);
+//		ListJoin<Order, String> note = order.join(Order_.notes);
+//		Expression<Set<Item>> items = order.get(Order_.items);
+//		order.fetch(Order_.items, JoinType.INNER);
+//
+//		q.select(note)
+//		 .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
+//	}
+
+	public void test4Untypesafe() {
+		CriteriaQuery<String> q = qb.createQuery( String.class );
+
+		Root<Order> order = q.from( Order.class );
+		ListJoin<Order, String> note = order.joinList( "notes" );
+		Expression<Set<Item>> items = order.get( "items" );
+		order.fetch( "items", INNER );
+
+		q.select( note )
+				.where( qb.and( qb.lt( note.index(), 10 ), qb.isNotEmpty( items ) ) );
+	}
+
+	/*public void test5() {
+		Expression<Long> l= null;
+		Expression<Integer> i= null;
+		Expression<Float> x= null;
+		Expression<Float> y= null;
+		
+		Expression<Number> n;
+		Expression<Float> f;
+		Expression<String> s = null;
+		
+		n = qb.quot(l, i);
+		
+		f = qb.sum(x, y);
+		
+		n = qb.quot(x, y);
+		
+		javax.jpamodelgen.criteria.Order o = qb.asc(n);
+		javax.jpamodelgen.criteria.Order p = qb.ascending(s);
+	}*/
+
+}


Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/QueryTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappingTest.java (from rev 17898, jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappingTest.java	                        (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappingTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,55 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlMappingTest {
+	@Test
+	public void testXmlConfiguredEmbeddedClassGenerated() throws Exception {
+		assertNotNull( Class.forName( "org.hibernate.jpamodelgen.test.model.xmlmapped.Address_" ) );
+	}
+
+	@Test
+	public void testXmlConfiguredMappedSuperclassGenerated() throws Exception {
+		Class<?> building = Class.forName( "org.hibernate.jpamodelgen.test.model.xmlmapped.Building_" );
+		assertNotNull( building );
+		assertNotNull( building.getField( "address" ) );
+	}
+
+	@Test
+	public void testClassHierarchy() throws Exception {
+		Class<?> mammal = Class.forName( "org.hibernate.jpamodelgen.test.model.xmlmapped.Mammal_" );
+		assertNotNull( mammal );
+
+		Class<?> being = Class.forName( "org.hibernate.jpamodelgen.test.model.xmlmapped.LivingBeing_" );
+		assertNotNull( being );
+
+		assertTrue( mammal.getSuperclass().equals( being ) );
+	}
+
+	@Test(expectedExceptions = ClassNotFoundException.class)
+	public void testNonExistentMappedClassesGetIgnored() throws Exception {
+		Class.forName( "org.hibernate.jpamodelgen.test.model.Dummy_" );
+	}
+}
\ No newline at end of file


Property changes on: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/XmlMappingTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model (from rev 17898, jpamodelgen/trunk/src/test/java/model)

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Address.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Address.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Address.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,12 +15,11 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import java.util.Set;
 import javax.persistence.Embeddable;
 import javax.persistence.Access;
-import javax.persistence.AccessType;
 import javax.persistence.ElementCollection;
 import javax.persistence.CollectionTable;
 

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Area.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Area.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Area.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.MappedSuperclass;
 

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Building.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Building.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Building.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.MappedSuperclass;
 

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Country.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Country.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Country.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Embeddable;
 

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Customer.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Customer.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Customer.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import java.util.Set;
 import javax.persistence.Entity;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Detail.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Detail.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Detail.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Embeddable;
 

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hominidae.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Hominidae.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Hominidae.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,11 +15,10 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Entity;
 import javax.persistence.Access;
-import javax.persistence.AccessType;
 
 /**
  * @author Emmanuel Bernard

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/House.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/House.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/House.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Id;
 import javax.persistence.Entity;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Human.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Human.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Human.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Entity;
 

Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Image.java (from rev 17898, jpamodelgen/trunk/src/test/java/model/Human.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Image.java	                        (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Image.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,46 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.model;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+ at Entity
+public class Image {
+	private String name;
+
+	private byte[] data;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public byte[] getData() {
+		return data;
+	}
+
+	public void setData(byte[] data) {
+		this.data = data;
+	}
+}
\ No newline at end of file

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Inhabitant.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Inhabitant.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Inhabitant.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,12 +15,11 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import java.util.Set;
 import javax.persistence.Embeddable;
 import javax.persistence.Access;
-import javax.persistence.AccessType;
 import javax.persistence.ElementCollection;
 
 /**

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Item.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Item.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Item.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,10 +15,9 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import java.util.Map;
-import java.util.Set;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/LivingBeing.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/LivingBeing.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/LivingBeing.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,11 +15,10 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.MappedSuperclass;
 import javax.persistence.Access;
-import javax.persistence.AccessType;
 
 /**
  * @author Emmanuel Bernard

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Mammals.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Mammals.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Mammals.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Order.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Order.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Order.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import java.util.Date;
 import java.util.List;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pet.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Pet.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Pet.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Embeddable;
 

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Product.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Product.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Product.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import java.math.BigDecimal;
 import java.util.Set;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Shop.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/Shop.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/Shop.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/User.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/User.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/User.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model;
+package org.hibernate.jpamodelgen.test.model;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Address.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/xmlmapped/Address.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Address.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.model.xmlmapped;
 
 /**
  * @author Hardy Ferentschik

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Building.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/xmlmapped/Building.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Building.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,10 +15,10 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.model.xmlmapped;
 
-import model.Address;
-import model.Area;
+import org.hibernate.jpamodelgen.test.model.Address;
+import org.hibernate.jpamodelgen.test.model.Area;
 
 /**
  * @author Hardy Ferentschik

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/LivingBeing.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/xmlmapped/LivingBeing.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/LivingBeing.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.model.xmlmapped;
 
 /**
  * @author Hardy Ferentschik

Modified: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Mammal.java
===================================================================
--- jpamodelgen/trunk/src/test/java/model/xmlmapped/Mammal.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/model/xmlmapped/Mammal.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.model.xmlmapped;
 
 /**
  * @author Hardy Ferentschik

Deleted: jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java
===================================================================
--- jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/test/AccessTypeTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,94 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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 test;
-
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-/**
- * @author Emmanuel Bernard
- */
- at Test
-public class AccessTypeTest {
-
-	@Test
-	public void testExcludeTransientFieldAndStatic() throws Exception{
-		absenceOfField( "model.Product_", "nonPersistent" );
-		absenceOfField( "model.Product_", "nonPersistent2" );
-	}
-
-	@Test
-	public void testDefaultAccessTypeOnEntity() throws Exception{
-		absenceOfField( "model.User_", "nonPersistent" );
-	}
-
-	@Test
-	public void testDefaultAccessTypeForSubclassOfEntity() throws Exception{
-		absenceOfField( "model.Customer_", "nonPersistent" );
-	}
-
-	@Test
-	public void testDefaultAccessTypeForEmbeddable() throws Exception{
-		absenceOfField( "model.Detail_", "nonPersistent" );
-	}
-
-	@Test
-	public void testInheritedAccessTypeForEmbeddable() throws Exception{
-		absenceOfField( "model.Country_", "nonPersistent" );
-		absenceOfField( "model.Pet_", "nonPersistent", "Colleciton of membeddable not taken care of" );
-	}
-
-	@Test
-	public void testDefaultAccessTypeForMappedSuperclass() throws Exception{
-		absenceOfField( "model.Detail_", "volume" );
-	}
-
-	@Test
-	public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Exception{
-		absenceOfField( "model.LivingBeing_", "nonPersistent", "eplicit access type on mapped superclass" );
-		absenceOfField( "model.Hominidae_", "nonPersistent", "eplicit access type on entity" );
-		absenceOfField( "model.Human_", "nonPersistent", "proper inheritance from root entity access type" );
-	}
-
-	@Test
-	public void testMemberAccessType() throws Exception{
-		presenceOfField( "model.Customer_", "goodPayer", "access type overriding" );
-	}
-
-	private void absenceOfField(String className, String fieldName) throws ClassNotFoundException {
-		absenceOfField( className, fieldName, "field should not be persistent" );
-	}
-	private void absenceOfField(String className, String fieldName, String errorString) throws ClassNotFoundException {
-		Assert.assertFalse( isFieldHere(className, fieldName), errorString );
-	}
-
-	private void presenceOfField(String className, String fieldName, String errorString) throws ClassNotFoundException {
-		Assert.assertTrue( isFieldHere(className, fieldName), errorString );
-	}
-
-	private boolean isFieldHere(String className, String fieldName) throws ClassNotFoundException {
-		Class<?> user_ = Class.forName( className );
-		try {
-			user_.getField( fieldName );
-			return true;
-		}
-		catch (NoSuchFieldException e) {
-			return false;
-		}
-	}
-}

Deleted: jpamodelgen/trunk/src/test/java/test/InheritanceTest.java
===================================================================
--- jpamodelgen/trunk/src/test/java/test/InheritanceTest.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/test/InheritanceTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,46 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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 test;
-
-import org.testng.annotations.Test;
-import org.testng.Assert;
-import model.Customer_;
-import model.User_;
-import model.House_;
-import model.Building_;
-import model.Area_;
-
-/**
- * @author Emmanuel Bernard
- */
- at Test
-public class InheritanceTest {
-	@Test
-	public void testSuperEntity() throws Exception {
-		Assert.assertEquals( Customer_.class.getSuperclass(), User_.class,
-				"Entity with super entity should inherit at the metamodel level");
-	}
-
-	@Test
-	public void testMappedSuperclass() throws Exception {
-		Assert.assertEquals( House_.class.getSuperclass(), Building_.class,
-				"Entity with mapped superclass should inherit at the metamodel level");
-		Assert.assertEquals( Building_.class.getSuperclass(), Area_.class,
-				"mapped superclass with mapped superclass should inherit at the metamodel level");
-	}
-}

Deleted: jpamodelgen/trunk/src/test/java/test/QueryTest.java
===================================================================
--- jpamodelgen/trunk/src/test/java/test/QueryTest.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/test/QueryTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,166 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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 test;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.Set;
-import javax.persistence.Tuple;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.Join;
-import static javax.persistence.criteria.JoinType.INNER;
-import javax.persistence.criteria.ListJoin;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Root;
-
-import model.Item;
-import model.Item_;
-import model.Order;
-import model.Order_;
-import model.Product;
-import model.Product_;
-import model.Shop_;
-
-/**
- * Writing queries involves passing typesafe, statically cached, metamodel
- * objects to the query builder in order to create the various parts of
- * the query. The typesafe metamodel objects were validated at init time,
- * so it is impossible to build invalid queries in the application code.
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class QueryTest {
-
-	CriteriaBuilder qb;
-
-	public void test() {
-		CriteriaQuery<Tuple> q = qb.createTupleQuery();
-
-		Root<Order> order = q.from( Order.class );
-		Join<Item, Product> product = order.join( Order_.items )
-				.join( Item_.product );
-
-		Path<BigDecimal> price = product.get( Product_.price );
-		Path<Boolean> filled = order.get( Order_.filled );
-		Path<Date> date = order.get( Order_.date );
-
-		q.select( qb.tuple( order, product ) )
-				.where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) )
-				.orderBy( qb.asc( price ), qb.desc( date ) );
-	}
-
-	public void testUntypesafe() {
-		CriteriaQuery<Tuple> q = qb.createTupleQuery();
-
-		Root<Order> order = q.from( Order.class );
-		Join<Item, Product> product = order.join( "items" )
-				.join( "product" );
-
-		Path<BigDecimal> price = product.get( "price" );
-		Path<Boolean> filled = order.get( "filled" );
-		Path<Date> date = order.get( "date" );
-
-		q.select( qb.tuple( order, product ) )
-				.where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) )
-				.orderBy( qb.asc( price ), qb.desc( date ) );
-	}
-
-	/**
-	 * Navigation by joining
-	 */
-	public void test2() {
-		CriteriaQuery<Product> q = qb.createQuery( Product.class );
-
-		Root<Product> product = q.from( Product.class );
-		Join<Item, Order> order = product.join( Product_.items )
-				.join( Item_.order );
-
-		q.select( product )
-				.where( qb.equal( order.get( Order_.id ), 12345l ) );
-	}
-
-	public void testMap() {
-		CriteriaQuery<Item> q = qb.createQuery( Item.class );
-
-		Root<Item> item = q.from( Item.class );
-		item.join( Item_.namedOrders );
-	}
-
-	/**
-	 * Navigation by compound Path
-	 */
-	public void test3() {
-		CriteriaQuery<Item> q = qb.createQuery( Item.class );
-
-		Root<Item> item = q.from( Item.class );
-		Path<String> shopName = item.get( Item_.order )
-				.get( Order_.shop )
-				.get( Shop_.name );
-		q.select( item )
-				.where( qb.equal( shopName, "amazon.com" ) );
-	}
-
-//	public void test4() {
-//		CriteriaQuery q = qb.create();
-//
-//		Root<Order> order = q.from(Order.class);
-//		ListJoin<Order, String> note = order.join(Order_.notes);
-//		Expression<Set<Item>> items = order.get(Order_.items);
-//		order.fetch(Order_.items, JoinType.INNER);
-//
-//		q.select(note)
-//		 .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
-//	}
-
-	public void test4Untypesafe() {
-		CriteriaQuery<String> q = qb.createQuery( String.class );
-
-		Root<Order> order = q.from( Order.class );
-		ListJoin<Order, String> note = order.joinList( "notes" );
-		Expression<Set<Item>> items = order.get( "items" );
-		order.fetch( "items", INNER );
-
-		q.select( note )
-				.where( qb.and( qb.lt( note.index(), 10 ), qb.isNotEmpty( items ) ) );
-	}
-
-	/*public void test5() {
-		Expression<Long> l= null;
-		Expression<Integer> i= null;
-		Expression<Float> x= null;
-		Expression<Float> y= null;
-		
-		Expression<Number> n;
-		Expression<Float> f;
-		Expression<String> s = null;
-		
-		n = qb.quot(l, i);
-		
-		f = qb.sum(x, y);
-		
-		n = qb.quot(x, y);
-		
-		javax.jpamodelgen.criteria.Order o = qb.asc(n);
-		javax.jpamodelgen.criteria.Order p = qb.ascending(s);
-	}*/
-
-}

Deleted: jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java
===================================================================
--- jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/java/test/XmlMappingTest.java	2009-11-03 14:52:05 UTC (rev 17899)
@@ -1,55 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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 test;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-/**
- * @author Hardy Ferentschik
- */
-public class XmlMappingTest {
-	@Test
-	public void testXmlConfiguredEmbeddedClassGenerated() throws Exception {
-		assertNotNull( Class.forName( "model.xmlmapped.Address_" ) );
-	}
-
-	@Test
-	public void testXmlConfiguredMappedSuperclassGenerated() throws Exception {
-		Class<?> building = Class.forName( "model.xmlmapped.Building_" );
-		assertNotNull( building );
-		assertNotNull( building.getField( "address" ) );
-	}
-
-	@Test
-	public void testClassHierarchy() throws Exception {
-		Class<?> mammal = Class.forName( "model.xmlmapped.Mammal_" );
-		assertNotNull( mammal );
-
-		Class<?> being = Class.forName( "model.xmlmapped.LivingBeing_" );
-		assertNotNull( being );
-
-		assertTrue( mammal.getSuperclass().equals( being ) );
-	}
-
-	@Test(expectedExceptions = ClassNotFoundException.class)
-	public void testNonExistentMappedClassesGetIgnored() throws Exception {
-		Class.forName( "model.Dummy_" );
-	}
-}
\ No newline at end of file

Modified: jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml
===================================================================
--- jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/resources/META-INF/dummy.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -5,7 +5,7 @@
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
                  version="2.0"
         >
-    <package>model</package>
+    <package>org.hibernate.jpamodelgen.test.model</package>
     <entity class="Dummy" access="FIELD" metadata-complete="true"> <!-- Class does not exist -->
         <attributes>
             <id name="id"/>

Modified: jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml
===================================================================
--- jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/resources/META-INF/jpa1-orm.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -5,7 +5,7 @@
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
                  version="1.0"
         >
-    <package>model</package>
+    <package>org.hibernate.jpamodelgen.test.model</package>
     <entity class="Airplane" metadata-complete="true" access="PROPERTY">
         <attributes>
             <id name="serialNumber"/>

Modified: jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml
===================================================================
--- jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/resources/META-INF/malformed-mapping-xml.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -5,7 +5,7 @@
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
                  version="2.0"
         >
-    <package>model</package>
+    <package>org.hibernate.jpamodelgen.test.model</package>
     <entity class="Dummy" access="FIELD" metadata-complete="true"> <!-- Class does not exist -->
         <attributes>
             <id name="id"/>

Modified: jpamodelgen/trunk/src/test/resources/META-INF/orm.xml
===================================================================
--- jpamodelgen/trunk/src/test/resources/META-INF/orm.xml	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/resources/META-INF/orm.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -5,7 +5,7 @@
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
                  version="2.0"
         >
-    <package>model</package>
+    <package>org.hibernate.jpamodelgen.test.model</package>
     <!-- default package -->
     <entity class="Order" access="FIELD" metadata-complete="true"> <!--means ignore annotations-->
         <attributes>

Modified: jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml
===================================================================
--- jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/resources/META-INF/persistence.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -7,8 +7,8 @@
         <mapping-file>/META-INF/dummy.xml</mapping-file>
         <mapping-file>/META-INF/malformed-mapping-xml.xml</mapping-file>
         <mapping-file>/META-INF/jpa1-orm.xml</mapping-file>
-        <mapping-file>/model/xmlmapped/address.xml</mapping-file>
-        <mapping-file>/model/xmlmapped/building.xml</mapping-file>
-        <mapping-file>/model/xmlmapped/mammal.xml</mapping-file>
+        <mapping-file>/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml</mapping-file>
+        <mapping-file>/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml</mapping-file>
+        <mapping-file>/org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml</mapping-file>
     </persistence-unit>
 </persistence>

Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml (from rev 17898, jpamodelgen/trunk/src/test/resources/model/xmlmapped/address.xml)
===================================================================
--- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml	                        (rev 0)
+++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,17 @@
+<?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 orm_2_0.xsd"
+                 version="2.0"
+        >
+    <package>org.hibernate.jpamodelgen.test.model.xmlmapped</package>  <!-- default package -->
+    <embeddable class="Address" access="FIELD" metadata-complete="true"> <!--means ignore annotations-->
+        <attributes>
+            <basic name="street1"/>
+            <basic name="city"/>
+            <basic name="country"/>
+        </attributes>
+    </embeddable>
+</entity-mappings>
+


Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/address.xml
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml (from rev 17898, jpamodelgen/trunk/src/test/resources/model/xmlmapped/building.xml)
===================================================================
--- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml	                        (rev 0)
+++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,15 @@
+<?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 orm_2_0.xsd"
+                 version="2.0"
+        >
+    <package>org.hibernate.jpamodelgen.test.model.xmlmapped</package>
+    <mapped-superclass class="Building" access="FIELD" metadata-complete="true"> <!--means ignore annotations-->
+        <attributes>
+            <one-to-one name="address" fetch="LAZY"/>
+        </attributes>
+    </mapped-superclass>
+</entity-mappings>
+


Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/building.xml
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml (from rev 17898, jpamodelgen/trunk/src/test/resources/model/xmlmapped/mammal.xml)
===================================================================
--- jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml	                        (rev 0)
+++ jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -0,0 +1,20 @@
+<?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 orm_2_0.xsd"
+                 version="2.0"
+        >
+    <package>org.hibernate.jpamodelgen.test.model.xmlmapped</package>
+    <entity class="LivingBeing" access="FIELD" metadata-complete="true">
+        <attributes>
+            <basic name="isReallyAlive"/>
+        </attributes>
+    </entity>
+    <entity class="Mammal" access="FIELD" metadata-complete="true">
+        <attributes>
+            <id name="id"/>
+            <basic name="subclass"/>
+        </attributes>
+    </entity>
+</entity-mappings>


Property changes on: jpamodelgen/trunk/src/test/resources/org/hibernate/jpamodelgen/test/model/xmlmapped/mammal.xml
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: jpamodelgen/trunk/src/test/suite/unit-tests.xml
===================================================================
--- jpamodelgen/trunk/src/test/suite/unit-tests.xml	2009-11-03 05:13:23 UTC (rev 17898)
+++ jpamodelgen/trunk/src/test/suite/unit-tests.xml	2009-11-03 14:52:05 UTC (rev 17899)
@@ -3,7 +3,7 @@
 <suite name="Hibernate Model Generator Tests" verbose="1">
     <test name="Unit tests">
         <packages>
-            <package name="test"/>
+            <package name="org.hibernate.jpamodelgen.test"/>
         </packages>
     </test>
 </suite>
\ No newline at end of file



More information about the hibernate-commits mailing list