Author: hardy.ferentschik
Date: 2009-01-26 13:10:53 -0500 (Mon, 26 Jan 2009)
New Revision: 13278
Added:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMap.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMember.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaMember.java
Removed:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
Modified:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
workspace/max/jpaap/test/src/META-INF/orm.xml
workspace/max/jpaap/test/src/Test.java
workspace/max/jpaap/test/src/model/Order.java
workspace/max/jpaap/test/src/model/Product.java
Log:
create Order_ from orm.xml
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaAttribute.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaAttribute.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaAttribute.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -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.jboss.jpa.metamodel.ap;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaAttribute extends IMetaMember {
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaCollection.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaCollection.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaCollection.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -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.jboss.jpa.metamodel.ap;
+
+import org.jboss.jpa.metamodel.ap.IMetaMember;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaCollection extends IMetaMember {
+}
Modified: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java 2009-01-26
18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -22,4 +22,10 @@
*/
public interface IMetaMember {
String getDeclarationString();
+
+ String getMetaType();
+
+ String getPropertyName();
+
+ String getTypeDeclaration();
}
Modified:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
---
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-26
18:00:58 UTC (rev 13277)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -13,14 +13,17 @@
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.TypeElement;
+import javax.lang.model.util.Elements;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
+import org.jboss.jpa.metamodel.ap.annotation.MetaEntity;
+import org.jboss.jpa.metamodel.ap.xml.XmlMetaEntity;
+
@SupportedAnnotationTypes("javax.persistence.Entity")
@SupportedSourceVersion(RELEASE_6)
public class JPAMetaModelEntityProcessor extends AbstractProcessor {
@@ -29,6 +32,8 @@
private static final Map<String, IMetaEntity> metaEntities = new
HashMap<String, IMetaEntity>();
+ private boolean ormProcessed = false;
+
public JPAMetaModelEntityProcessor() {
}
@@ -41,10 +46,10 @@
* Tries to check whether a orm.xml file exists and parses it using JAXB
*/
private void parsingOrmXml() {
- System.out.println("Checking for orm.xml");
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Checking for
orm.xml");
InputStream ormStream = this.getClass().getResourceAsStream(ORM_XML_LOCATION);
if (ormStream == null) {
- System.out.println("No orm.xml found.");
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "No
orm.xml found.");
return;
}
try {
@@ -54,22 +59,16 @@
Collection<Entity> entities = mappings.getEntity();
String packageName = mappings.getPackage();
for (Entity entity : entities) {
- String fullyQualifiedClassName = packageName + "." +
entity.getClazz();
- Element typeElement =
processingEnv.getElementUtils().getTypeElement(fullyQualifiedClassName);
- MetaEntity metaEntity = new MetaEntity(processingEnv, (TypeElement)
typeElement);
+ String fullyQualifiedClassName = packageName + "." +
entity.getClazz();
+ Elements utils = processingEnv.getElementUtils();
+ XmlMetaEntity metaEntity = new XmlMetaEntity(entity, packageName,
utils.getTypeElement(fullyQualifiedClassName));
+ writeFile(metaEntity);
- // TODO
- // here we would like to somehow take the XML info and merge it into the
MetaEntity
- // or maybe create interfaces for the MetaXXX classes. One set of
implementation could be backed by
- // TypeEelement and one by the xml Entity
-
-
-
// keep track of alreay processed entities
metaEntities.put(fullyQualifiedClassName, metaEntity);
}
} catch (JAXBException e) {
- System.err.println("Error unmarshalling orm.xml");
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Error
unmarshalling orm.xml");
e.printStackTrace();
}
}
@@ -86,7 +85,7 @@
final RoundEnvironment aRoundEnvironment) {
- if (aRoundEnvironment.processingOver()) { // No need to run since all our output
needs to be considered
+ if (aRoundEnvironment.processingOver()) {
return false;
}
@@ -109,11 +108,8 @@
if (element.getKind() == ElementKind.CLASS &&
annotationType.equals(javax.persistence.Entity.class.getName())) {
-
MetaEntity metaEntity = new MetaEntity(processingEnv, (TypeElement)
element);
-
writeFile(metaEntity);
-
}
}
}
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java 2009-01-26
18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -1,16 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import javax.lang.model.element.Element;
-
-public class MetaAttribute extends MetaMember {
-
- public MetaAttribute(MetaEntity parent, Element element, String type) {
- super(parent, element, type);
- }
-
- @Override
- protected String getMetaType() {
- return "javax.jpa.metamodel.Attribute";
- }
-
-}
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
===================================================================
---
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java 2009-01-26
18:00:58 UTC (rev 13277)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -1,22 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import javax.lang.model.element.Element;
-
-
-public class MetaCollection extends MetaMember {
-
- private String collectionType;
-
-
- public MetaCollection(MetaEntity parent, Element element, String collectionType, String
elementType) {
- super(parent, element, elementType);
- this.collectionType = collectionType;
- }
-
- @Override
- protected String getMetaType() {
- return collectionType;
- }
-
-
-}
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-26
18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -1,217 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-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.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.tools.Diagnostic.Kind;
-
-public class MetaEntity implements IMetaEntity {
-
- final TypeElement element;
- final protected ProcessingEnvironment pe;
-
- final ImportContext importContext;
-
- public MetaEntity(ProcessingEnvironment pe, TypeElement element) {
- this.element = element;
- this.pe = pe;
- importContext = new ImportContextImpl(getPackageName().toString());
- }
-
- 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() +
".metamodel").toString();
- }
-
- public List<IMetaMember> getMembers() {
-
- List<IMetaMember> members = new ArrayList<IMetaMember>();
-
- if (useFields()) {
-
- List<? extends Element> myMembers =
ElementFilter.fieldsIn(element.getEnclosedElements());
-
- System.out.println("Scanning " + myMembers.size() + " field s
for " + element.toString());
-
- for (Element mymember : myMembers) {
-
- MetaMember result = mymember.asType().accept(new TypeVisitor(this),
mymember);
- if (result != null) {
- members.add(result);
- } else {
- pe.getMessager().printMessage(Kind.WARNING, "Could not find
valid info for JPA property", mymember);
- }
- }
-
- } else {
-
-
- List<? extends Element> myMembers =
ElementFilter.methodsIn(element.getEnclosedElements());
-
- System.out.println("Scanning " + myMembers.size() + " methods
for " + element.toString());
- for (Element mymember : myMembers) {
-
- MetaMember result = mymember.asType().accept(new TypeVisitor(this),
mymember);
- if (result != null) {
- members.add(result);
- } else {
- //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA
property", mymember);
- }
- }
-
- }
-
- if (members.size() == 0) {
- pe.getMessager().printMessage(Kind.WARNING, "No properties found on
" + element, element);
- }
- return members;
- }
-
-
- //TODO: Find more efficient way to identify wether we should use fields or
properties
- private boolean useFields() {
- List<? extends Element> myMembers = element.getEnclosedElements();
- for (Element element : myMembers) {
- List<? extends AnnotationMirror> entityAnnotations =
- pe.getElementUtils().getAllAnnotationMirrors(element);
-
- for (Iterator<?> iterator = entityAnnotations.iterator(); iterator
- .hasNext();) {
- AnnotationMirror annotationMirror = (AnnotationMirror) iterator
- .next();
-
- final String annotationType =
annotationMirror.getAnnotationType().toString();
-
- if (annotationType.equals(javax.persistence.Id.class.getName()) ||
-
annotationType.equals(javax.persistence.EmbeddedId.class.getName())) {
- if (element.getKind() == ElementKind.FIELD) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
-
- static Map<String, String> COLLECTIONS = new HashMap<String, String>();
-
- static {
- COLLECTIONS.put("java.util.Collection",
"javax.jpa.metamodel.Collection");
- COLLECTIONS.put("java.util.Set", "javax.jpa.metamodel.Set");
- COLLECTIONS.put("java.util.List",
"javax.jpa.metamodel.List");
- COLLECTIONS.put("java.util.Map", "javax.jpa.metamodel.Map");
- }
-
- class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
-
- MetaEntity parent;
-
- TypeVisitor(MetaEntity parent) {
- this.parent = parent;
- }
-
- @Override
- protected MetaMember defaultAction(TypeMirror e, Element p) {
- //System.out.println("Default action for: " + e + " on "
+ p);
- //new Exception().printStackTrace();
- return super.defaultAction(e, p);
- }
-
- @Override
- public MetaMember visitPrimitive(PrimitiveType t, Element p) {
- return new MetaAttribute(parent, p, TypeUtils.toTypeString(t));
- }
-
-
- @Override
- public MetaMember visitDeclared(DeclaredType t, Element p) {
- TypeElement e = (TypeElement) pe.getTypeUtils().asElement(t);
-
- String collection = COLLECTIONS.get(e.getQualifiedName().toString()); //
WARNING: .toString() is necessary here since Name equals does not compare to String
- if (collection != null) {
- if (collection.equals("javax.jpa.metamodel.Map")) {
- return new MetaMap(parent, p, collection, getKeyType(t),
getElementType(t));
- } else {
- return new MetaCollection(parent, p, collection, getElementType(t));
- }
- } else {
- return new MetaAttribute(parent, p, e.getQualifiedName().toString());
- }
- }
-
-
- @Override
- public MetaMember 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());
- }
-
- private String getKeyType(DeclaredType t) {
- System.out.println("key type" + 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java 2009-01-26
18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -1,19 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import javax.lang.model.element.Element;
-
-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 " + parent.importType(getMetaType()) + "<"
+ parent.importType(parent.getQualifiedName()) + ", " +
parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) +
"> " + getPropertyName() + ";";
- }
-
-}
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-26
18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -1,52 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import java.beans.Introspector;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Name;
-
-public abstract class MetaMember implements IMetaMember {
-
- final protected Element element;
- final protected MetaEntity parent;
- final protected ProcessingEnvironment pe;
- private final String type;
-
- public MetaMember(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 " + parent.importType(getMetaType()) + "<"
+ parent.importType(parent.getQualifiedName()) + ", " +
parent.importType(getTypeDeclaration()) + "> " + getPropertyName() +
";";
- }
-
- protected Name getPropertyName() {
- if(element.getKind()==ElementKind.FIELD) {
- return element.getSimpleName();
- } 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())));
- } else if(name.startsWith("is")) {
- return
(pe.getElementUtils().getName(Introspector.decapitalize(name.substring("is".length()))));
- }
- return pe.getElementUtils().getName(Introspector.decapitalize(name));
- } else {
- return pe.getElementUtils().getName(element.getSimpleName() + "/* " +
element.getKind() + " */");
- }
- }
-
- abstract protected String getMetaType();
-
-
- protected String getTypeDeclaration() {
- return type;
- }
-
-}
Copied:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaAttribute.java
(from rev 13111,
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java)
===================================================================
---
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaAttribute.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaAttribute.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,18 @@
+package org.jboss.jpa.metamodel.ap.annotation;
+
+import org.jboss.jpa.metamodel.ap.IMetaAttribute;
+
+import javax.lang.model.element.Element;
+
+public class MetaAttribute extends MetaMember implements IMetaAttribute {
+
+ public MetaAttribute(MetaEntity parent, Element element, String type) {
+ super(parent, element, type);
+ }
+
+ @Override
+ public String getMetaType() {
+ return "javax.jpa.metamodel.Attribute";
+ }
+
+}
Copied:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaCollection.java
(from rev 13111,
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java)
===================================================================
---
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaCollection.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaCollection.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,24 @@
+package org.jboss.jpa.metamodel.ap.annotation;
+
+import org.jboss.jpa.metamodel.ap.IMetaCollection;
+
+import javax.lang.model.element.Element;
+
+
+public class MetaCollection extends MetaMember 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;
+ }
+
+
+}
Copied:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaEntity.java (from
rev 13152, workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java)
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaEntity.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaEntity.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,217 @@
+package org.jboss.jpa.metamodel.ap.annotation;
+
+import org.jboss.jpa.metamodel.ap.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+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.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.tools.Diagnostic.Kind;
+
+public class MetaEntity implements IMetaEntity {
+
+ final TypeElement element;
+ final protected ProcessingEnvironment pe;
+
+ final ImportContext importContext;
+
+ public MetaEntity(ProcessingEnvironment pe, TypeElement element) {
+ this.element = element;
+ this.pe = pe;
+ importContext = new ImportContextImpl(getPackageName().toString());
+ }
+
+ 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() +
".metamodel").toString();
+ }
+
+ public List<IMetaMember> getMembers() {
+
+ List<IMetaMember> members = new ArrayList<IMetaMember>();
+
+ if (useFields()) {
+
+ List<? extends Element> myMembers =
ElementFilter.fieldsIn(element.getEnclosedElements());
+
+ System.out.println("Scanning " + myMembers.size() + " field s
for " + element.toString());
+
+ for (Element mymember : myMembers) {
+
+ MetaMember result = mymember.asType().accept(new TypeVisitor(this),
mymember);
+ if (result != null) {
+ members.add(result);
+ } else {
+ pe.getMessager().printMessage(Kind.WARNING, "Could not find
valid info for JPA property", mymember);
+ }
+ }
+
+ } else {
+
+
+ List<? extends Element> myMembers =
ElementFilter.methodsIn(element.getEnclosedElements());
+
+ System.out.println("Scanning " + myMembers.size() + " methods
for " + element.toString());
+ for (Element mymember : myMembers) {
+
+ MetaMember result = mymember.asType().accept(new TypeVisitor(this),
mymember);
+ if (result != null) {
+ members.add(result);
+ } else {
+ //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA
property", mymember);
+ }
+ }
+
+ }
+
+ if (members.size() == 0) {
+ pe.getMessager().printMessage(Kind.WARNING, "No properties found on
" + element, element);
+ }
+ return members;
+ }
+
+
+ //TODO: Find more efficient way to identify wether we should use fields or
properties
+ private boolean useFields() {
+ List<? extends Element> myMembers = element.getEnclosedElements();
+ for (Element element : myMembers) {
+ List<? extends AnnotationMirror> entityAnnotations =
+ pe.getElementUtils().getAllAnnotationMirrors(element);
+
+ for (Iterator<?> iterator = entityAnnotations.iterator(); iterator
+ .hasNext();) {
+ AnnotationMirror annotationMirror = (AnnotationMirror) iterator
+ .next();
+
+ final String annotationType =
annotationMirror.getAnnotationType().toString();
+
+ if (annotationType.equals(javax.persistence.Id.class.getName()) ||
+
annotationType.equals(javax.persistence.EmbeddedId.class.getName())) {
+ if (element.getKind() == ElementKind.FIELD) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+
+ static {
+ COLLECTIONS.put("java.util.Collection",
"javax.jpa.metamodel.Collection");
+ COLLECTIONS.put("java.util.Set", "javax.jpa.metamodel.Set");
+ COLLECTIONS.put("java.util.List",
"javax.jpa.metamodel.List");
+ COLLECTIONS.put("java.util.Map", "javax.jpa.metamodel.Map");
+ }
+
+ class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
+
+ MetaEntity parent;
+
+ TypeVisitor(MetaEntity parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ protected MetaMember defaultAction(TypeMirror e, Element p) {
+ return super.defaultAction(e, p);
+ }
+
+ @Override
+ public MetaMember visitPrimitive(PrimitiveType t, Element p) {
+ return new MetaAttribute(parent, p, TypeUtils.toTypeString(t));
+ }
+
+
+ @Override
+ public MetaMember visitDeclared(DeclaredType t, Element p) {
+ TypeElement e = (TypeElement) pe.getTypeUtils().asElement(t);
+
+ String collection = COLLECTIONS.get(e.getQualifiedName().toString()); //
WARNING: .toString() is necessary here since Name equals does not compare to String
+ if (collection != null) {
+ if (collection.equals("javax.jpa.metamodel.Map")) {
+ return new MetaMap(parent, p, collection, getKeyType(t),
getElementType(t));
+ } else {
+ return new MetaCollection(parent, p, collection, getElementType(t));
+ }
+ } else {
+ return new MetaAttribute(parent, p, e.getQualifiedName().toString());
+ }
+ }
+
+
+ @Override
+ public MetaMember 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());
+ }
+
+ private String getKeyType(DeclaredType t) {
+ System.out.println("key type" + 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();
+ }
+ }
+}
Copied: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMap.java
(from rev 13111, workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java)
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMap.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMap.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,19 @@
+package org.jboss.jpa.metamodel.ap.annotation;
+
+import javax.lang.model.element.Element;
+
+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 " + parent.importType(getMetaType()) + "<"
+ parent.importType(parent.getQualifiedName()) + ", " +
parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) +
"> " + getPropertyName() + ";";
+ }
+
+}
Copied:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMember.java (from
rev 13152, workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java)
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMember.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/annotation/MetaMember.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,52 @@
+package org.jboss.jpa.metamodel.ap.annotation;
+
+import org.jboss.jpa.metamodel.ap.IMetaMember;
+
+import java.beans.Introspector;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+
+public abstract class MetaMember implements IMetaMember {
+
+ final protected Element element;
+ final protected MetaEntity parent;
+ final protected ProcessingEnvironment pe;
+ private final String type;
+
+ public MetaMember(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 " + 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;
+ }
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaAttribute.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaAttribute.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaAttribute.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,35 @@
+// $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.jboss.jpa.metamodel.ap.xml;
+
+import org.jboss.jpa.metamodel.ap.IMetaAttribute;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlMetaAttribute extends XmlMetaMember implements IMetaAttribute {
+
+ public XmlMetaAttribute(XmlMetaEntity parent, String propertyName, String type) {
+ super(parent, propertyName, type);
+ }
+
+ @Override
+ public String getMetaType() {
+ return "javax.jpa.metamodel.Attribute";
+ }
+}
Added:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaCollection.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaCollection.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaCollection.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,38 @@
+// $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.jboss.jpa.metamodel.ap.xml;
+
+import org.jboss.jpa.metamodel.ap.IMetaCollection;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlMetaCollection extends XmlMetaMember implements IMetaCollection {
+
+ String collectionType;
+
+ public XmlMetaCollection(XmlMetaEntity parent, String propertyName, String type,
String collectionType) {
+ super(parent, propertyName, type);
+ this.collectionType = collectionType;
+ }
+
+ @Override
+ public String getMetaType() {
+ return collectionType;
+ }
+}
\ No newline at end of file
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaEntity.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaEntity.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -0,0 +1,173 @@
+// $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.jboss.jpa.metamodel.ap.xml;
+
+import com.sun.java.xml.ns.persistence.orm.*;
+import org.jboss.jpa.metamodel.ap.IMetaEntity;
+import org.jboss.jpa.metamodel.ap.IMetaMember;
+import org.jboss.jpa.metamodel.ap.ImportContext;
+import org.jboss.jpa.metamodel.ap.ImportContextImpl;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlMetaEntity implements IMetaEntity {
+
+ static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+
+ static {
+ COLLECTIONS.put("java.util.Collection",
"javax.jpa.metamodel.Collection");
+ COLLECTIONS.put("java.util.Set", "javax.jpa.metamodel.Set");
+ COLLECTIONS.put("java.util.List",
"javax.jpa.metamodel.List");
+ COLLECTIONS.put("java.util.Map", "javax.jpa.metamodel.Map");
+ }
+
+ final private Entity ormEntity;
+
+ final private String packageName;
+
+ final private ImportContext importContext;
+
+ final private List<IMetaMember> members = new ArrayList<IMetaMember>();
+
+ private TypeElement type;
+
+ public XmlMetaEntity(Entity ormEntity, String packageName, TypeElement type) {
+ this.ormEntity = ormEntity;
+ this.packageName = packageName;
+ importContext = new ImportContextImpl(getPackageName());
+ this.type = type;
+ Attributes attributes = ormEntity.getAttributes();
+ Id id = attributes.getId().get(0);
+ XmlMetaAttribute attribute = new XmlMetaAttribute(this, id.getName(),
getType(id.getName()));
+ members.add(attribute);
+
+ for (Basic basic : attributes.getBasic()) {
+ attribute = new XmlMetaAttribute(this, basic.getName(),
getType(basic.getName()));
+ members.add(attribute);
+ }
+
+ for (ManyToOne manyToOne : attributes.getManyToOne()) {
+ attribute = new XmlMetaAttribute(this, manyToOne.getName(),
getType(manyToOne.getName()));
+ members.add(attribute);
+ }
+
+ XmlMetaCollection metaCollection;
+ for (OneToMany oneToMany : attributes.getOneToMany()) {
+ String[] types = getCollectionType(oneToMany.getName());
+ metaCollection = new XmlMetaCollection(this, oneToMany.getName(), types[0],
types[1]);
+ members.add(metaCollection);
+ }
+
+ for (ElementCollection collection : attributes.getElementCollection()) {
+ String[] types = getCollectionType(collection.getName());
+ metaCollection = new XmlMetaCollection(this, collection.getName(), types[0],
types[1]);
+ members.add(metaCollection);
+ }
+ }
+
+ @Override
+ public String getSimpleName() {
+ return ormEntity.getClazz();
+ }
+
+ @Override
+ public String getQualifiedName() {
+ return packageName + "." + getSimpleName();
+ }
+
+ @Override
+ public String getPackageName() {
+ return packageName + ".metamodel";
+ }
+
+ @Override
+ public List<IMetaMember> getMembers() {
+ return members;
+ }
+
+ 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());
+ }
+
+ private String[] getCollectionType(String propertyName) {
+ String types[] = new String[2];
+ for (Element elem : type.getEnclosedElements()) {
+ if (elem.getSimpleName().toString().equals(propertyName)) {
+ DeclaredType type = ((DeclaredType) elem.asType());
+ types[0] = type.getTypeArguments().get(0).toString();
+ types[1] = COLLECTIONS.get(type.asElement().toString());
+ }
+ }
+ return types;
+ }
+
+ // TODO - so far only prototype. Only tested for the Order orm.xml
+ private String getType(String propertyName) {
+ String typeName = null;
+ for (Element elem : type.getEnclosedElements()) {
+ if (elem.getSimpleName().toString().equals(propertyName)) {
+ switch (elem.asType().getKind()) {
+ case INT: {
+ typeName = "java.lang.Integer";
+ break;
+ }
+ case LONG: {
+ typeName = "java.lang.Long";
+ break;
+ }
+ case BOOLEAN: {
+ typeName = "java.lang.Boolean";
+ break;
+ }
+ case DECLARED: {
+ typeName = ((DeclaredType) elem.asType()).toString();
+ break;
+ }
+ case TYPEVAR: {
+ typeName = ((DeclaredType) elem.asType()).toString();
+ break;
+ }
+ }
+ break;
+ }
+ }
+ return typeName;
+ }
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaMember.java
(rev 0)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/xml/XmlMetaMember.java 2009-01-26
18:10:53 UTC (rev 13278)
@@ -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.jboss.jpa.metamodel.ap.xml;
+
+import org.jboss.jpa.metamodel.ap.IMetaMember;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public abstract class XmlMetaMember implements IMetaMember {
+
+ private XmlMetaEntity parentEntity;
+
+ private String propertyName;
+
+ private String type;
+
+ XmlMetaMember(XmlMetaEntity parent, String propertyName, String type) {
+ this.parentEntity = parent;
+ this.propertyName = propertyName;
+ this.type = type;
+ }
+
+
+ @Override
+ public String getDeclarationString() {
+ return "public static " + parentEntity.importType(getMetaType()) +
"<" + parentEntity.importType(parentEntity.getQualifiedName()) + ",
" + parentEntity.importType(getTypeDeclaration()) + "> " +
getPropertyName() + ";";
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public String getTypeDeclaration() {
+ return type;
+ }
+
+ @Override
+ abstract public String getMetaType();
+}
Modified: workspace/max/jpaap/test/src/META-INF/orm.xml
===================================================================
--- workspace/max/jpaap/test/src/META-INF/orm.xml 2009-01-26 18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/test/src/META-INF/orm.xml 2009-01-26 18:10:53 UTC (rev 13278)
@@ -13,6 +13,7 @@
<column name="fld_id"/>
</id>
<basic name="filled"></basic>
+ <basic name="date"></basic>
<one-to-many name="items" target-entity="Item"
fetch="EAGER"> <!-- target-entity optional guess the type from the
geenric-->
<cascade>
<cascade-persist/>
Modified: workspace/max/jpaap/test/src/Test.java
===================================================================
--- workspace/max/jpaap/test/src/Test.java 2009-01-26 18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/test/src/Test.java 2009-01-26 18:10:53 UTC (rev 13278)
@@ -11,6 +11,7 @@
import javax.jpa.criteria.Query;
import javax.jpa.criteria.QueryBuilder;
import javax.jpa.criteria.Root;
+import javax.jpa.metamodel.Entity;
import model.metamodel.Item_;
import model.metamodel.Order_;
Modified: workspace/max/jpaap/test/src/model/Order.java
===================================================================
--- workspace/max/jpaap/test/src/model/Order.java 2009-01-26 18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/test/src/model/Order.java 2009-01-26 18:10:53 UTC (rev 13278)
@@ -1,28 +1,28 @@
package model;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
-@Entity
+//@Entity
public class Order {
- @Id
+ //@Id
long id;
- @OneToMany
+ //@OneToMany
Set<Item> items;
boolean filled;
Date date;
- @OneToMany
+ //@OneToMany
List<String> notes;
- @ManyToOne
+ //@ManyToOne
Shop shop;
}
Modified: workspace/max/jpaap/test/src/model/Product.java
===================================================================
--- workspace/max/jpaap/test/src/model/Product.java 2009-01-26 18:00:58 UTC (rev 13277)
+++ workspace/max/jpaap/test/src/model/Product.java 2009-01-26 18:10:53 UTC (rev 13278)
@@ -13,6 +13,8 @@
@Id
long id;
+
+ int test;
String description;
BigDecimal price;