[hibernate-commits] Hibernate SVN: r17010 - in jpamodelgen/trunk: generator and 22 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue Jul 7 05:04:47 EDT 2009
Author: hardy.ferentschik
Date: 2009-07-07 05:04:46 -0400 (Tue, 07 Jul 2009)
New Revision: 17010
Added:
jpamodelgen/trunk/generator/
jpamodelgen/trunk/generator/pom.xml
jpamodelgen/trunk/generator/src/
jpamodelgen/trunk/generator/src/main/
jpamodelgen/trunk/generator/src/main/java/
jpamodelgen/trunk/generator/src/main/java/org/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaAttribute.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaCollection.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaEntity.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaMember.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContext.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContextImpl.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/TypeUtils.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaAttribute.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaCollection.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMap.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMember.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaAttribute.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaCollection.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaEntity.java
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaMember.java
jpamodelgen/trunk/generator/src/main/resources/
jpamodelgen/trunk/generator/src/main/resources/META-INF/
jpamodelgen/trunk/generator/src/main/resources/META-INF/services/
jpamodelgen/trunk/generator/src/main/resources/META-INF/services/javax.annotation.processing.Processor
jpamodelgen/trunk/generator/src/main/xsd/
jpamodelgen/trunk/generator/src/main/xsd/orm_2_0.xsd
jpamodelgen/trunk/generator/src/test/
jpamodelgen/trunk/generator/src/test/java/
jpamodelgen/trunk/generator/src/test/resources/
jpamodelgen/trunk/pom.xml
jpamodelgen/trunk/test/
jpamodelgen/trunk/test/pom.xml
jpamodelgen/trunk/test/src/
jpamodelgen/trunk/test/src/main/
jpamodelgen/trunk/test/src/main/java/
jpamodelgen/trunk/test/src/main/java/Test.java
jpamodelgen/trunk/test/src/main/java/model/
jpamodelgen/trunk/test/src/main/java/model/Item.java
jpamodelgen/trunk/test/src/main/java/model/Order.java
jpamodelgen/trunk/test/src/main/java/model/Product.java
jpamodelgen/trunk/test/src/main/java/model/Shop.java
jpamodelgen/trunk/test/src/main/resources/
jpamodelgen/trunk/test/src/main/resources/META-INF/
jpamodelgen/trunk/test/src/main/resources/META-INF/orm.xml
Log:
initial checkin
Added: jpamodelgen/trunk/generator/pom.xml
===================================================================
--- jpamodelgen/trunk/generator/pom.xml (rev 0)
+++ jpamodelgen/trunk/generator/pom.xml 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,99 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodel-generator-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodel-generator</artifactId>
+ <name>Hibernate JPA Model Generator</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ </dependency>
+
+ <!--
+ Test dependencies
+ -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>test</defaultGoal>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xjc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <packageName>org.hibernate.jpa.metamodel.xml.jaxb</packageName>
+ <outputDirectory>${basedir}/target/generated-sources</outputDirectory>
+ <extension>true</extension>
+ </configuration>
+ </plugin>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-test-report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report-only</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
+ <outputName>test-report</outputName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaAttribute.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaAttribute.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaAttribute.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.jpa.metamodel.ap;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaAttribute extends IMetaMember {
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaCollection.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaCollection.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaCollection.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.jpa.metamodel.ap;
+
+import org.hibernate.jpa.metamodel.ap.IMetaMember;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaCollection extends IMetaMember {
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaEntity.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaEntity.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaEntity.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.jpa.metamodel.ap;
+
+import javax.lang.model.element.Name;
+import java.util.List;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaEntity extends ImportContext {
+ String getSimpleName();
+
+ String getQualifiedName();
+
+ String getPackageName();
+
+ List<IMetaMember> getMembers();
+
+ String generateImports();
+
+ String importType(String fqcn);
+
+ String staticImport(String fqcn, String member);
+
+ String importType(Name qualifiedName);
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaMember.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaMember.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/IMetaMember.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.jpa.metamodel.ap;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaMember {
+ String getDeclarationString();
+
+ String getMetaType();
+
+ String getPropertyName();
+
+ String getTypeDeclaration();
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContext.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContext.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContext.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,23 @@
+package org.hibernate.jpa.metamodel.ap;
+
+public interface ImportContext {
+
+ /**
+ * Add fqcn to the import list. Returns fqcn as needed in source code.
+ * Attempts to handle fqcn with array and generics references.
+ *
+ * e.g.
+ * java.util.Collection<org.marvel.Hulk> imports java.util.Collection and returns Collection
+ * org.marvel.Hulk[] imports org.marvel.Hulk and returns Hulk
+ *
+ *
+ * @param fqcn
+ * @return import string
+ */
+ public abstract String importType(String fqcn);
+
+ public abstract String staticImport(String fqcn, String member);
+
+ public abstract String generateImports();
+
+}
\ No newline at end of file
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContextImpl.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContextImpl.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/ImportContextImpl.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,162 @@
+package org.hibernate.jpa.metamodel.ap;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+
+
+public class ImportContextImpl implements ImportContext {
+
+ Set<String> imports = new TreeSet<String>();
+ Set<String> staticImports = new TreeSet<String>();
+ Map<String, String> simpleNames = new HashMap<String, String>();
+
+ String basePackage = "";
+
+ private static final Map<String, String> PRIMITIVES = new HashMap<String, String>();
+ static {
+ PRIMITIVES.put( "char", "Character" );
+
+ PRIMITIVES.put( "byte", "Byte" );
+ PRIMITIVES.put( "short", "Short" );
+ PRIMITIVES.put( "int", "Integer" );
+ PRIMITIVES.put( "long", "Long" );
+
+ PRIMITIVES.put( "boolean", "Boolean" );
+
+ PRIMITIVES.put( "float", "Float" );
+ PRIMITIVES.put( "double", "Double" );
+
+ }
+
+ public ImportContextImpl(String basePackage) {
+ this.basePackage = basePackage;
+ }
+
+ /**
+ * Add fqcn to the import list. Returns fqcn as needed in source code.
+ * Attempts to handle fqcn with array and generics references.
+ *
+ * e.g.
+ * java.util.Collection<org.marvel.Hulk> imports java.util.Collection and returns Collection
+ * org.marvel.Hulk[] imports org.marvel.Hulk and returns Hulk
+ *
+ *
+ * @param fqcn
+ * @return import string
+ */
+ public String importType(String fqcn) {
+ String result = fqcn;
+
+ //if(fqcn==null) return "/** (null) **/";
+
+ String additionalTypePart = null;
+ if(fqcn.indexOf('<')>=0) {
+ additionalTypePart = result.substring(fqcn.indexOf('<'));
+ result = result.substring(0,fqcn.indexOf('<'));
+ fqcn = result;
+ } else if(fqcn.indexOf('[')>=0) {
+ additionalTypePart = result.substring(fqcn.indexOf('['));
+ result = result.substring(0,fqcn.indexOf('['));
+ fqcn = result;
+ }
+
+ String pureFqcn = fqcn.replace( '$', '.' );
+
+ boolean canBeSimple = true;
+
+
+ String simpleName = unqualify(fqcn);
+ if(simpleNames.containsKey(simpleName)) {
+ String existingFqcn = simpleNames.get(simpleName);
+ if(existingFqcn.equals(pureFqcn)) {
+ canBeSimple = true;
+ } else {
+ canBeSimple = false;
+ }
+ } else {
+ canBeSimple = true;
+ simpleNames.put(simpleName, pureFqcn);
+ imports.add( pureFqcn );
+ }
+
+
+ if ( inSamePackage(fqcn) || (imports.contains( pureFqcn ) && canBeSimple) ) {
+ result = unqualify( result ); // dequalify
+ } else if ( inJavaLang( fqcn ) ) {
+ result = result.substring( "java.lang.".length() );
+ }
+
+ if(additionalTypePart!=null) {
+ result = result + additionalTypePart;
+ }
+
+ result = result.replace( '$', '.' );
+ return result;
+ }
+
+ public String staticImport(String fqcn, String member) {
+ String local = fqcn + "." + member;
+ imports.add(local);
+ staticImports.add(local);
+
+ if(member.equals("*")) {
+ return "";
+ } else {
+ return member;
+ }
+ }
+
+ private boolean inDefaultPackage(String className) {
+ return className.indexOf( "." ) < 0;
+ }
+
+ private boolean isPrimitive(String className) {
+ return PRIMITIVES.containsKey( className );
+ }
+
+ private boolean inSamePackage(String className) {
+ String other = qualifier( className );
+ return other == basePackage
+ || (other != null && other.equals( basePackage ) );
+ }
+
+ private boolean inJavaLang(String className) {
+ return "java.lang".equals( qualifier( className ) );
+ }
+
+ public String generateImports() {
+ StringBuffer buf = new StringBuffer();
+
+ for ( Iterator<String> imps = imports.iterator(); imps.hasNext(); ) {
+ String next = imps.next();
+ if(isPrimitive(next) || inDefaultPackage(next) || inJavaLang(next) || inSamePackage(next)) {
+ // dont add automatically "imported" stuff
+ } else {
+ if(staticImports.contains(next)) {
+ buf.append("import static " + next + ";\r\n");
+ } else {
+ buf.append("import " + next + ";\r\n");
+ }
+ }
+ }
+
+ if(buf.indexOf( "$" )>=0) {
+ return buf.toString();
+ }
+ return buf.toString();
+ }
+
+ public static String unqualify(String qualifiedName) {
+ int loc = qualifiedName.lastIndexOf(".");
+ return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( qualifiedName.lastIndexOf(".") + 1 );
+ }
+
+ public static String qualifier(String qualifiedName) {
+ int loc = qualifiedName.lastIndexOf(".");
+ return ( loc < 0 ) ? "" : qualifiedName.substring( 0, loc );
+ }
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,236 @@
+package org.hibernate.jpa.metamodel.ap;
+
+
+
+import static javax.lang.model.SourceVersion.RELEASE_6;
+
+import java.io.*;
+import java.util.*;
+
+import javax.annotation.Generated;
+import javax.annotation.processing.*;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.Elements;
+import javax.tools.Diagnostic;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.hibernate.jpa.metamodel.ap.annotation.MetaEntity;
+import org.hibernate.jpa.metamodel.ap.xml.XmlMetaEntity;
+import org.hibernate.jpa.metamodel.xml.jaxb.Entity;
+import org.hibernate.jpa.metamodel.xml.jaxb.EntityMappings;
+import org.hibernate.jpa.metamodel.xml.jaxb.ObjectFactory;
+
+//@SupportedAnnotationTypes("javax.persistence.Entity")
+ at SupportedAnnotationTypes("*") // TODO: this is not very effective
+ at SupportedSourceVersion(RELEASE_6)
+public class JPAMetaModelEntityProcessor extends AbstractProcessor {
+
+ //private static final String ORM_XML_LOCATION = "/META-INF/orm.xml";
+
+ private static final Map<String, IMetaEntity> metaEntities = new HashMap<String, IMetaEntity>();
+
+ private boolean ormProcessed = false;
+
+ public JPAMetaModelEntityProcessor() {
+ System.out.println("Created Processor " + this);
+ }
+
+ public void init(ProcessingEnvironment env) {
+ super.init(env);
+ System.out.println("Init Processor " + this);
+ }
+
+ private void parsingOrmXmls() {
+ //make sure that we process ORM files only once per round
+ if (ormProcessed) return;
+ parsingOrmXml("/META-INF", "orm.xml");
+ //simulate 20 different ORM files to parse
+ //Removed since these causes issues in Eclipse APT
+ //for (int i = 1 ; i <= 20 ; i++) parsingOrmXml("/model" + i , "orm.xml");
+
+ ormProcessed = true;
+ }
+
+ /**
+ * Tries to check whether a orm.xml file exists and parses it using JAXB
+ */
+ private void parsingOrmXml(String pkg, String name) {
+ String resource = pkg +"/"+name;
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "XYZ Checking for " + resource);
+
+ InputStream ormStream = null;
+ try {
+ FileObject resource2 = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, pkg, name);
+ ormStream = resource2.openInputStream();
+ } catch (IOException e1) {
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "Could not locate " + resource + " via APT api");
+ //TODO: possible remove this fallback since it should not be needed.
+ ormStream = this.getClass().getResourceAsStream(resource);
+ }
+
+ if (ormStream == null) {
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, resource + " not found.");
+ return;
+ }
+ try {
+ JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class);
+ Unmarshaller unmarshaller = jc.createUnmarshaller();
+ EntityMappings mappings = (EntityMappings) unmarshaller.unmarshal(ormStream);
+ Collection<Entity> entities = mappings.getEntity();
+ String packageName = mappings.getPackage();
+ for (Entity entity : entities) {
+ String fullyQualifiedClassName = packageName + "." + entity.getClazz();
+ Elements utils = processingEnv.getElementUtils();
+ XmlMetaEntity metaEntity = new XmlMetaEntity(entity, packageName, utils.getTypeElement(fullyQualifiedClassName));
+ writeFile(metaEntity);
+
+ // keep track of alreay processed entities
+ metaEntities.put(fullyQualifiedClassName, metaEntity);
+ }
+ } catch (JAXBException e) {
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Error unmarshalling orm.xml");
+ e.printStackTrace();
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem while reading " + resource + " " + e.getMessage());
+ e.printStackTrace();
+ //TODO: too bad you can't mark resources as having issues
+ }
+ }
+
+ /**
+ * Process JPA-specific annotations in Java entity classes.
+ *
+ * @param aAnnotations Matching annotations to be processed.
+ * @param aRoundEnvironment Annotation processing round environment.
+ * @return
+ */
+ @Override
+ public boolean process(final Set<? extends TypeElement> aAnnotations,
+ final RoundEnvironment aRoundEnvironment) {
+
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Processing annotations:" + aAnnotations);
+
+ StringBuilder sb = new StringBuilder("xxx" + new Date().toLocaleString());
+ Set<? extends Element> elements = aRoundEnvironment.getRootElements();
+ sb.append("\n\n");
+ for (Element element : elements) {
+ sb.append(element.toString());
+ sb.append("\n");
+ handleRootElementAnnotationMirrors(element);
+ }
+
+ sb.append("xxx");
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, sb.toString());
+
+
+ if (aRoundEnvironment.processingOver()) {
+ //assuming that when processing is over, we are done and clear resources like ORM parsing
+ //we could keep some ORM parsing in memory but how to detect that a file has changed / not changed?
+ ormProcessed = false;
+ metaEntities.clear();
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Clear ORM processing resources");
+ return false;
+ }
+ parsingOrmXmls();
+ for (Element element : elements) {
+ handleRootElementAnnotationMirrors(element);
+ }
+
+ return true;
+ }
+
+ private void handleRootElementAnnotationMirrors(final Element element) {
+
+ List<? extends AnnotationMirror> annotationMirrors = element
+ .getAnnotationMirrors();
+
+ for (AnnotationMirror mirror : annotationMirrors) {
+ final String annotationType = mirror.getAnnotationType().toString();
+
+ if (element.getKind() == ElementKind.CLASS &&
+ annotationType.equals(javax.persistence.Entity.class.getName())) {
+ MetaEntity metaEntity = new MetaEntity(processingEnv, (TypeElement) element);
+ writeFile(metaEntity);
+ }
+ }
+ }
+
+ private void writeFile(IMetaEntity entity) {
+
+ try {
+ String metaModelPackage = entity.getPackageName();
+
+ StringBuffer body = generateBody(entity);
+
+ FileObject fo = processingEnv.getFiler().createSourceFile(
+ metaModelPackage + "." + entity.getSimpleName() + "_");
+ OutputStream os = fo.openOutputStream();
+ PrintWriter pw = new PrintWriter(os);
+
+ pw.println("package " + metaModelPackage + ";");
+
+ pw.println();
+
+ pw.println(entity.generateImports());
+
+ pw.println(body);
+
+ pw.flush();
+ pw.close();
+
+ } catch (FilerException filerEx) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem with Processing Environment Filer: "
+ + filerEx.getMessage());
+ } catch (IOException ioEx) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.ERROR,
+ "Problem opening file to write MetaModel for " + entity.getSimpleName()
+ + ioEx.getMessage());
+ }
+ }
+
+ /**
+ * Generate everything after import statements
+ *
+ * @return body content
+ */
+ private StringBuffer generateBody(IMetaEntity entity) {
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = null;
+ try {
+
+ pw = new PrintWriter(sw);
+
+ pw.println("@" + entity.importType(Generated.class.getName()) + "(\"JPA MetaModel for " + entity.getQualifiedName() + "\")");
+
+ pw.println("@" + entity.importType("javax.persistence.metamodel.TypesafeMetamodel") + "(" + entity.getSimpleName() + ".class)");
+
+ pw.println("public abstract class " + entity.getSimpleName() + "_" + " {");
+
+ pw.println();
+
+ List<IMetaMember> members = entity.getMembers();
+
+ for (IMetaMember metaMember : members) {
+ pw.println(" " + metaMember.getDeclarationString());
+ }
+ pw.println();
+ pw.println("}");
+ return sw.getBuffer();
+ } finally {
+ if (pw != null) pw.close();
+ }
+ }
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,33 @@
+package org.hibernate.jpa.metamodel.ap;
+
+public class JpaAnnotationsConstants
+{
+ public static final String ANNOTATION_KEY_ALLOCATION_SIZE = "allocationSize()";
+ public static final String ANNOTATION_KEY_COLUMN_DEFINITION = "columnDefinition()";
+ public static final String ANNOTATION_KEY_DISCRIMINATOR_TYPE =
+ "discriminatorType()";
+ public static final String ANNOTATION_KEY_INITIAL_VALUE = "initialValue()";
+ public static final String ANNOTATION_KEY_GENERATOR = "generator()";
+ public static final String ANNOTATION_KEY_INSERTABLE = "insertable()";
+ public static final String ANNOTATION_KEY_INVERSE_JOIN_COLUMNS =
+ "inverseJoinColumns()";
+ public static final String ANNOTATION_KEY_JOIN_COLUMNS = "joinColumns()";
+ public static final String ANNOTATION_KEY_LENGTH = "length()";
+ public static final String ANNOTATION_KEY_MAPPED_BY = "mappedBy()";
+ public static final String ANNOTATION_KEY_NAME = "name()";
+ public static final String ANNOTATION_KEY_NULLABLE = "nullable()";
+ public static final String ANNOTATION_KEY_QUERY = "query()";
+ public static final String ANNOTATION_KEY_REFERENCED_COLUMN_NAME =
+ "referencedColumnName()";
+ public static final String ANNOTATION_KEY_SEQUENCE_NAME = "sequenceName()";
+ public static final String ANNOTATION_KEY_STRATEGY = "strategy()";
+ public static final String ANNOTATION_TARGET_ENTITY = "targetEntity()";
+ public static final String ANNOTATION_KEY_VALUE = "value()";
+
+ public static final String JPA_VERSION = "1.0";
+
+ public static final String PROCESSOR_USER_OPTION_XML_OVERRIDE =
+ "xmlOverrideAnnotations";
+ public static final String PROCESSOR_USER_OPTION_UPPER_COLUMN_NAMES =
+ "useUpperCaseColumnNames";
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/TypeUtils.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/TypeUtils.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/TypeUtils.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,33 @@
+package org.hibernate.jpa.metamodel.ap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.lang.model.type.TypeMirror;
+
+public class TypeUtils {
+
+ private static final Map<String, String> PRIMITIVES = new HashMap<String, String>();
+ static {
+ PRIMITIVES.put( "char", "Character" );
+
+ PRIMITIVES.put( "byte", "Byte" );
+ PRIMITIVES.put( "short", "Short" );
+ PRIMITIVES.put( "int", "Integer" );
+ PRIMITIVES.put( "long", "Long" );
+
+ PRIMITIVES.put( "boolean", "Boolean" );
+
+ PRIMITIVES.put( "float", "Float" );
+ PRIMITIVES.put( "double", "Double" );
+
+ }
+
+ static public String toTypeString(TypeMirror type) {
+ if(type.getKind().isPrimitive()) {
+ return PRIMITIVES.get(type.toString());
+ }
+
+ return type.toString();
+ }
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaAttribute.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaAttribute.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaAttribute.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,18 @@
+package org.hibernate.jpa.metamodel.ap.annotation;
+
+import org.hibernate.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.persistence.metamodel.Attribute";
+ }
+
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaCollection.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaCollection.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaCollection.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,24 @@
+package org.hibernate.jpa.metamodel.ap.annotation;
+
+import org.hibernate.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;
+ }
+
+
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaEntity.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,217 @@
+package org.hibernate.jpa.metamodel.ap.annotation;
+
+import org.hibernate.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.persistence.metamodel.Collection");
+ COLLECTIONS.put("java.util.Set", "javax.persistence.metamodel.Set");
+ COLLECTIONS.put("java.util.List", "javax.persistence.metamodel.List");
+ COLLECTIONS.put("java.util.Map", "javax.persistence.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.persistence.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();
+ }
+ }
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMap.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMap.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMap.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,19 @@
+package org.hibernate.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() + ";";
+ }
+
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMember.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMember.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/annotation/MetaMember.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,51 @@
+package org.hibernate.jpa.metamodel.ap.annotation;
+
+import org.hibernate.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;
+
+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: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaAttribute.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaAttribute.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaAttribute.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.hibernate.jpa.metamodel.ap.xml;
+
+import org.hibernate.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.persistence.metamodel.Attribute";
+ }
+}
Added: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaCollection.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaCollection.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaCollection.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.hibernate.jpa.metamodel.ap.xml;
+
+import org.hibernate.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: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaEntity.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaEntity.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaEntity.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,175 @@
+// $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.jpa.metamodel.ap.xml;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+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 org.hibernate.jpa.metamodel.ap.IMetaEntity;
+import org.hibernate.jpa.metamodel.ap.IMetaMember;
+import org.hibernate.jpa.metamodel.ap.ImportContext;
+import org.hibernate.jpa.metamodel.ap.ImportContextImpl;
+import org.hibernate.jpa.metamodel.xml.jaxb.Attributes;
+import org.hibernate.jpa.metamodel.xml.jaxb.Basic;
+import org.hibernate.jpa.metamodel.xml.jaxb.ElementCollection;
+import org.hibernate.jpa.metamodel.xml.jaxb.Entity;
+import org.hibernate.jpa.metamodel.xml.jaxb.Id;
+import org.hibernate.jpa.metamodel.xml.jaxb.ManyToOne;
+import org.hibernate.jpa.metamodel.xml.jaxb.OneToMany;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlMetaEntity implements IMetaEntity {
+
+ static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+
+ static {
+ COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.Collection" );
+ COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.Set" );
+ COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.List" );
+ COLLECTIONS.put( "java.util.Map", "javax.persistence.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 );
+ }
+ }
+
+ public String getSimpleName() {
+ return ormEntity.getClazz();
+ }
+
+ public String getQualifiedName() {
+ return packageName + "." + getSimpleName();
+ }
+
+ public String getPackageName() {
+ return packageName + ".metamodel";
+ }
+
+ 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: jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaMember.java
===================================================================
--- jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaMember.java (rev 0)
+++ jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/xml/XmlMetaMember.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -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.jpa.metamodel.ap.xml;
+
+import org.hibernate.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();
+}
Added: jpamodelgen/trunk/generator/src/main/resources/META-INF/services/javax.annotation.processing.Processor
===================================================================
--- jpamodelgen/trunk/generator/src/main/resources/META-INF/services/javax.annotation.processing.Processor (rev 0)
+++ jpamodelgen/trunk/generator/src/main/resources/META-INF/services/javax.annotation.processing.Processor 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1 @@
+org.hibernate.jpa.metamodel.ap.JPAMetaModelEntityProcessor
\ No newline at end of file
Added: jpamodelgen/trunk/generator/src/main/xsd/orm_2_0.xsd
===================================================================
--- jpamodelgen/trunk/generator/src/main/xsd/orm_2_0.xsd (rev 0)
+++ jpamodelgen/trunk/generator/src/main/xsd/orm_2_0.xsd 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,1504 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Java Persistence API object/relational mapping file schema -->
+<xsd:schema targetNamespace="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified" attributeFormDefault="unqualified"
+ version="2.0">
+ <xsd:annotation>
+ <xsd:documentation>
+ @(#)orm_2_0.xsd 2.0 August 27 2008
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+This is the XML Schema for the persistence object/relational
+mapping file.
+The file may be named "META-INF/orm.xml" in the persistence
+archive or it may be named some other name which would be
+used to locate the file as resource on the classpath.
+Object/relational mapping files must indicate the object/relational
+mapping file schema by using the persistence namespace:
+http://java.sun.com/xml/ns/persistence
+and indicate the version of the schema by
+using the version element as shown below:
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
+http://java.sun.com/xml/ns/persistence/orm/orm_2_0.xsd"
+version="2.0">
+...
+</entity-mappings>
+]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType name="emptyType" />
+ <xsd:simpleType name="versionType">
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[0-9]+(\.[0-9]+)*" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:element name="entity-mappings">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ The entity-mappings element is the root element of
+ an mapping file. It contains the following four
+ types of elements: 1. The persistence-unit-metadata
+ element contains metadata for the entire persistence
+ unit. It is undefined if this element occurs in
+ multiple mapping files within the same persistence
+ unit. 2. The package, schema, catalog and access
+ elements apply to all of the entity,
+ mapped-superclass and embeddable elements defined in
+ the same file in which they occur. 3. The
+ sequence-generator, table-generator, named-query,
+ named-native-query and sql-result-set-mapping
+ elements are global to the persistence unit. It is
+ undefined to have more than one sequence-generator
+ or table-generator of the same name in the same or
+ different mapping files in a persistence unit. It is
+ also undefined to have more than one named-query,
+ named-native-query, or result-set-mapping of the
+ same name in the same or different mapping files in
+ a persistence unit. 4. The entity, mapped-superclass
+ and embeddable elements each define the mapping
+ information for a managed persistent class. The
+ mapping information contained in these elements may
+ be complete or it may be partial.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="persistence-unit-metadata"
+ type="orm:persistence-unit-metadata" minOccurs="0" />
+ <xsd:element name="package" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="schema" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="catalog" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="access" type="orm:access-type"
+ minOccurs="0" />
+ <xsd:element name="sequence-generator"
+ type="orm:sequence-generator" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="table-generator"
+ type="orm:table-generator" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="named-query" type="orm:named-query"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="named-native-query"
+ type="orm:named-native-query" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="sql-result-set-mapping"
+ type="orm:sql-result-set-mapping" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="mapped-superclass"
+ type="orm:mapped-superclass" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="entity" type="orm:entity"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="embeddable" type="orm:embeddable"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="version" type="orm:versionType"
+ fixed="2.0" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:complexType name="persistence-unit-metadata">
+ <xsd:annotation>
+ <xsd:documentation>
+ Metadata that applies to the persistence unit and not
+ just to the mapping file in which it is contained. If
+ the xml-mapping-metadata-complete element is specified,
+ the complete set of mapping metadata for the persistence
+ unit is contained in the XML mapping files for the
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="xml-mapping-metadata-complete"
+ type="orm:emptyType" minOccurs="0" />
+ <xsd:element name="persistence-unit-defaults"
+ type="orm:persistence-unit-defaults" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="persistence-unit-defaults">
+ <xsd:annotation>
+ <xsd:documentation>
+ These defaults are applied to the persistence unit as a
+ whole unless they are overridden by local annotation or
+ XML element settings. schema - Used as the schema for
+ all tables, secondary tables, collection tables,
+ sequence generators, and table generators that apply to
+ the persistence unit catalog - Used as the catalog for
+ all tables, secondary tables, collection tables,
+ sequence generators, and table generators that apply to
+ the persistence unit access - Used as the access type
+ for all managed classes in the persistence unit
+ cascade-persist - Adds cascade-persist to the set of
+ cascade options in all entity relationships of the
+ persistence unit entity-listeners - List of default
+ entity listeners to be invoked on each entity in the
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="schema" type="xsd:string" minOccurs="0" />
+ <xsd:element name="catalog" type="xsd:string" minOccurs="0" />
+ <xsd:element name="access" type="orm:access-type"
+ minOccurs="0" />
+ <xsd:element name="cascade-persist" type="orm:emptyType"
+ minOccurs="0" />
+ <xsd:element name="entity-listeners"
+ type="orm:entity-listeners" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="entity">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines the settings and mappings for an entity. Is
+ allowed to be sparsely populated and used in conjunction
+ with the annotations. Alternatively, the
+ metadata-complete attribute can be used to indicate that
+ no annotations on the entity class (and its fields or
+ properties) are to be processed. If this is the case
+ then the defaulting rules for the entity and its
+ subelements will be recursively applied. @Target(TYPE)
+ @Retention(RUNTIME) public @interface Entity { String
+ name() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="table" type="orm:table" minOccurs="0" />
+ <xsd:element name="secondary-table"
+ type="orm:secondary-table" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="primary-key-join-column"
+ type="orm:primary-key-join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="id-class" type="orm:id-class"
+ minOccurs="0" />
+ <xsd:element name="inheritance" type="orm:inheritance"
+ minOccurs="0" />
+ <xsd:element name="discriminator-value"
+ type="orm:discriminator-value" minOccurs="0" />
+ <xsd:element name="discriminator-column"
+ type="orm:discriminator-column" minOccurs="0" />
+ <xsd:element name="sequence-generator"
+ type="orm:sequence-generator" minOccurs="0" />
+ <xsd:element name="table-generator"
+ type="orm:table-generator" minOccurs="0" />
+ <xsd:element name="named-query" type="orm:named-query"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="named-native-query"
+ type="orm:named-native-query" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="sql-result-set-mapping"
+ type="orm:sql-result-set-mapping" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="exclude-default-listeners"
+ type="orm:emptyType" minOccurs="0" />
+ <xsd:element name="exclude-superclass-listeners"
+ type="orm:emptyType" minOccurs="0" />
+ <xsd:element name="entity-listeners"
+ type="orm:entity-listeners" minOccurs="0" />
+ <xsd:element name="pre-persist" type="orm:pre-persist"
+ minOccurs="0" />
+ <xsd:element name="post-persist" type="orm:post-persist"
+ minOccurs="0" />
+ <xsd:element name="pre-remove" type="orm:pre-remove"
+ minOccurs="0" />
+ <xsd:element name="post-remove" type="orm:post-remove"
+ minOccurs="0" />
+ <xsd:element name="pre-update" type="orm:pre-update"
+ minOccurs="0" />
+ <xsd:element name="post-update" type="orm:post-update"
+ minOccurs="0" />
+ <xsd:element name="post-load" type="orm:post-load"
+ minOccurs="0" />
+ <xsd:element name="attribute-override"
+ type="orm:attribute-override" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="association-override"
+ type="orm:association-override" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="attributes" type="orm:attributes"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="class" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="metadata-complete" type="xsd:boolean" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="access-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ This element determines how the persistence provider
+ accesses the state of an entity or embedded object.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="PROPERTY" />
+ <xsd:enumeration value="FIELD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="association-override">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+ public @interface AssociationOverride { String name();
+ JoinColumn[] joinColumns() default{}; JoinTable
+ joinTable() default @JoinTable; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="join-column" type="orm:join-column"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="join-table" type="orm:join-table"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="attribute-override">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+ public @interface AttributeOverride { String name();
+ Column column(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="column" type="orm:column" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="attributes">
+ <xsd:annotation>
+ <xsd:documentation>
+ This element contains the entity field or property
+ mappings. It may be sparsely populated to include only a
+ subset of the fields or properties. If metadata-complete
+ for the entity is true then the remainder of the
+ attributes will be defaulted according to the default
+ rules.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:choice>
+ <xsd:element name="id" type="orm:id" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="embedded-id" type="orm:embedded-id"
+ minOccurs="0" />
+ </xsd:choice>
+ <xsd:element name="basic" type="orm:basic" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="version" type="orm:version" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="many-to-one" type="orm:many-to-one"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="one-to-many" type="orm:one-to-many"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="one-to-one" type="orm:one-to-one"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="many-to-many" type="orm:many-to-many"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="element-collection"
+ type="orm:element-collection" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="embedded" type="orm:embedded"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="transient" type="orm:transient"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="basic">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Basic { FetchType fetch() default EAGER;
+ boolean optional() default true; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="column" type="orm:column" minOccurs="0" />
+ <xsd:choice>
+ <xsd:element name="lob" type="orm:lob" minOccurs="0" />
+ <xsd:element name="temporal" type="orm:temporal"
+ minOccurs="0" />
+ <xsd:element name="enumerated" type="orm:enumerated"
+ minOccurs="0" />
+ </xsd:choice>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="fetch" type="orm:fetch-type" />
+ <xsd:attribute name="optional" type="xsd:boolean" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="cascade-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum CascadeType { ALL, PERSIST, MERGE, REMOVE,
+ REFRESH};
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="cascade-all" type="orm:emptyType"
+ minOccurs="0" />
+ <xsd:element name="cascade-persist" type="orm:emptyType"
+ minOccurs="0" />
+ <xsd:element name="cascade-merge" type="orm:emptyType"
+ minOccurs="0" />
+ <xsd:element name="cascade-remove" type="orm:emptyType"
+ minOccurs="0" />
+ <xsd:element name="cascade-refresh" type="orm:emptyType"
+ minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="collection-table">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface CollectionTable { String name() default "";
+ String catalog() default ""; String schema() default "";
+ JoinColumn[] joinColumns() default {};
+ UniqueConstraint[] uniqueConstraints() default {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="join-column" type="orm:join-column"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="unique-constraint"
+ type="orm:unique-constraint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="catalog" type="xsd:string" />
+ <xsd:attribute name="schema" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Column { String name() default ""; boolean
+ unique() default false; boolean nullable() default true;
+ boolean insertable() default true; boolean updatable()
+ default true; String columnDefinition() default "";
+ String table() default ""; int length() default 255; int
+ precision() default 0; // decimal precision int scale()
+ default 0; // decimal scale }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="unique" type="xsd:boolean" />
+ <xsd:attribute name="nullable" type="xsd:boolean" />
+ <xsd:attribute name="insertable" type="xsd:boolean" />
+ <xsd:attribute name="updatable" type="xsd:boolean" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ <xsd:attribute name="table" type="xsd:string" />
+ <xsd:attribute name="length" type="xsd:int" />
+ <xsd:attribute name="precision" type="xsd:int" />
+ <xsd:attribute name="scale" type="xsd:int" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="column-result">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({}) @Retention(RUNTIME) public @interface
+ ColumnResult { String name(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="discriminator-column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ DiscriminatorColumn { String name() default "DTYPE";
+ DiscriminatorType discriminatorType() default STRING;
+ String columnDefinition() default ""; int length()
+ default 31; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="discriminator-type"
+ type="orm:discriminator-type" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ <xsd:attribute name="length" type="xsd:int" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="discriminator-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum DiscriminatorType { STRING, CHAR, INTEGER };
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="STRING" />
+ <xsd:enumeration value="CHAR" />
+ <xsd:enumeration value="INTEGER" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="discriminator-value">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ DiscriminatorValue { String value(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="element-collection">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface ElementCollection { Class targetClass()
+ default void.class; FetchType fetch() default LAZY; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="column" type="orm:column" minOccurs="0" />
+ <xsd:choice>
+ <xsd:element name="order-by" type="orm:order-by"
+ minOccurs="0" />
+ <xsd:element name="order-column" type="orm:order-column"
+ minOccurs="0" />
+ </xsd:choice>
+ <xsd:choice>
+ <xsd:element name="map-key" type="orm:map-key"
+ minOccurs="0" />
+ <xsd:sequence>
+ <xsd:element name="map-key-class"
+ type="orm:map-key-class" minOccurs="0" />
+ <xsd:choice>
+ <xsd:element name="map-key-column"
+ type="orm:map-key-column" minOccurs="0" />
+ <xsd:element name="map-key-join-column"
+ type="orm:map-key-join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:choice>
+ <xsd:element name="collection-table"
+ type="orm:collection-table" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="target-entity" type="xsd:string" />
+ <xsd:attribute name="fetch" type="orm:fetch-type" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="embeddable">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines the settings and mappings for embeddable
+ objects. Is allowed to be sparsely populated and used in
+ conjunction with the annotations. Alternatively, the
+ metadata-complete attribute can be used to indicate that
+ no annotations are to be processed in the class. If this
+ is the case then the defaulting rules will be
+ recursively applied. @Target({TYPE}) @Retention(RUNTIME)
+ public @interface Embeddable {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="attributes"
+ type="orm:embeddable-attributes" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="class" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="metadata-complete" type="xsd:boolean" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="embeddable-attributes">
+ <xsd:sequence>
+ <xsd:element name="basic" type="orm:basic" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="many-to-one" type="orm:many-to-one"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="one-to-many" type="orm:one-to-many"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="one-to-one" type="orm:one-to-one"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="many-to-many" type="orm:many-to-many"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="element-collection"
+ type="orm:element-collection" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="embedded" type="orm:embedded"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="transient" type="orm:transient"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="embedded">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Embedded {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="attribute-override"
+ type="orm:attribute-override" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="association-override"
+ type="orm:association-override" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="embedded-id">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface EmbeddedId {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="attribute-override"
+ type="orm:attribute-override" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="entity-listener">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines an entity listener to be invoked at lifecycle
+ events for the entities that list this listener.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="pre-persist" type="orm:pre-persist"
+ minOccurs="0" />
+ <xsd:element name="post-persist" type="orm:post-persist"
+ minOccurs="0" />
+ <xsd:element name="pre-remove" type="orm:pre-remove"
+ minOccurs="0" />
+ <xsd:element name="post-remove" type="orm:post-remove"
+ minOccurs="0" />
+ <xsd:element name="pre-update" type="orm:pre-update"
+ minOccurs="0" />
+ <xsd:element name="post-update" type="orm:post-update"
+ minOccurs="0" />
+ <xsd:element name="post-load" type="orm:post-load"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="class" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="entity-listeners">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ EntityListeners { Class[] value(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="entity-listener"
+ type="orm:entity-listener" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="entity-result">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({}) @Retention(RUNTIME) public @interface
+ EntityResult { Class entityClass(); FieldResult[]
+ fields() default {}; String discriminatorColumn()
+ default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="field-result" type="orm:field-result"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="entity-class" type="xsd:string"
+ use="required" />
+ <xsd:attribute name="discriminator-column" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="enum-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum EnumType { ORDINAL, STRING }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="ORDINAL" />
+ <xsd:enumeration value="STRING" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="enumerated">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Enumerated { EnumType value() default
+ ORDINAL; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="orm:enum-type" />
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="fetch-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum FetchType { LAZY, EAGER };
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="LAZY" />
+ <xsd:enumeration value="EAGER" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="field-result">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({}) @Retention(RUNTIME) public @interface
+ FieldResult { String name(); String column(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="column" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="generated-value">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface GeneratedValue { GenerationType strategy()
+ default AUTO; String generator() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="strategy" type="orm:generation-type" />
+ <xsd:attribute name="generator" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="generation-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum GenerationType { TABLE, SEQUENCE, IDENTITY,
+ AUTO };
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="TABLE" />
+ <xsd:enumeration value="SEQUENCE" />
+ <xsd:enumeration value="IDENTITY" />
+ <xsd:enumeration value="AUTO" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="id">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Id {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="column" type="orm:column" minOccurs="0" />
+ <xsd:element name="generated-value"
+ type="orm:generated-value" minOccurs="0" />
+ <xsd:element name="temporal" type="orm:temporal"
+ minOccurs="0" />
+ <xsd:element name="table-generator"
+ type="orm:table-generator" minOccurs="0" />
+ <xsd:element name="sequence-generator"
+ type="orm:sequence-generator" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="id-class">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ IdClass { Class value(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="class" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="inheritance">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ Inheritance { InheritanceType strategy() default
+ SINGLE_TABLE; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="strategy" type="orm:inheritance-type" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="inheritance-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum InheritanceType { SINGLE_TABLE, JOINED,
+ TABLE_PER_CLASS};
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="SINGLE_TABLE" />
+ <xsd:enumeration value="JOINED" />
+ <xsd:enumeration value="TABLE_PER_CLASS" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="join-column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface JoinColumn { String name() default ""; String
+ referencedColumnName() default ""; boolean unique()
+ default false; boolean nullable() default true; boolean
+ insertable() default true; boolean updatable() default
+ true; String columnDefinition() default ""; String
+ table() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="referenced-column-name" type="xsd:string" />
+ <xsd:attribute name="unique" type="xsd:boolean" />
+ <xsd:attribute name="nullable" type="xsd:boolean" />
+ <xsd:attribute name="insertable" type="xsd:boolean" />
+ <xsd:attribute name="updatable" type="xsd:boolean" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ <xsd:attribute name="table" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="join-table">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface JoinTable { String name() default ""; String
+ catalog() default ""; String schema() default "";
+ JoinColumn[] joinColumns() default {}; JoinColumn[]
+ inverseJoinColumns() default {}; UniqueConstraint[]
+ uniqueConstraints() default {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="join-column" type="orm:join-column"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="inverse-join-column"
+ type="orm:join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="unique-constraint"
+ type="orm:unique-constraint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="catalog" type="xsd:string" />
+ <xsd:attribute name="schema" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="lob">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Lob {}
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="many-to-many">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface ManyToMany { Class targetEntity() default
+ void.class; CascadeType[] cascade() default {};
+ FetchType fetch() default LAZY; String mappedBy()
+ default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:element name="order-by" type="orm:order-by"
+ minOccurs="0" />
+ <xsd:element name="order-column" type="orm:order-column"
+ minOccurs="0" />
+ </xsd:choice>
+ <xsd:choice>
+ <xsd:element name="map-key" type="orm:map-key"
+ minOccurs="0" />
+ <xsd:sequence>
+ <xsd:element name="map-key-class"
+ type="orm:map-key-class" minOccurs="0" />
+ <xsd:choice>
+ <xsd:element name="map-key-column"
+ type="orm:map-key-column" minOccurs="0" />
+ <xsd:element name="map-key-join-column"
+ type="orm:map-key-join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:choice>
+ <xsd:element name="join-table" type="orm:join-table"
+ minOccurs="0" />
+ <xsd:element name="cascade" type="orm:cascade-type"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="target-entity" type="xsd:string" />
+ <xsd:attribute name="fetch" type="orm:fetch-type" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="mapped-by" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="many-to-one">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface ManyToOne { Class targetEntity() default
+ void.class; CascadeType[] cascade() default {};
+ FetchType fetch() default EAGER; boolean optional()
+ default true; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:element name="join-column" type="orm:join-column"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="join-table" type="orm:join-table"
+ minOccurs="0" />
+ </xsd:choice>
+ <xsd:element name="cascade" type="orm:cascade-type"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="target-entity" type="xsd:string" />
+ <xsd:attribute name="fetch" type="orm:fetch-type" />
+ <xsd:attribute name="optional" type="xsd:boolean" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="mapped-by-id" type="xsd:string" />
+ <xsd:attribute name="id" type="xsd:boolean" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="map-key">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface MapKey { String name() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="map-key-class">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface MapKeyClass { Class value(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="class" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="map-key-column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface MapKeyColumn { String name() default "";
+ boolean unique() default false; boolean nullable()
+ default false; boolean insertable() default true;
+ boolean updatable() default true; String
+ columnDefinition() default ""; String table() default
+ ""; int length() default 255; int precision() default 0;
+ // decimal precision int scale() default 0; // decimal
+ scale }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="unique" type="xsd:boolean" />
+ <xsd:attribute name="nullable" type="xsd:boolean" />
+ <xsd:attribute name="insertable" type="xsd:boolean" />
+ <xsd:attribute name="updatable" type="xsd:boolean" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ <xsd:attribute name="table" type="xsd:string" />
+ <xsd:attribute name="length" type="xsd:int" />
+ <xsd:attribute name="precision" type="xsd:int" />
+ <xsd:attribute name="scale" type="xsd:int" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="map-key-join-column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface MapKeyJoinColumn { String name() default "";
+ String referencedColumnName() default ""; boolean
+ unique() default false; boolean nullable() default
+ false; boolean insertable() default true; boolean
+ updatable() default true; String columnDefinition()
+ default ""; String table() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="referenced-column-name" type="xsd:string" />
+ <xsd:attribute name="unique" type="xsd:boolean" />
+ <xsd:attribute name="nullable" type="xsd:boolean" />
+ <xsd:attribute name="insertable" type="xsd:boolean" />
+ <xsd:attribute name="updatable" type="xsd:boolean" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ <xsd:attribute name="table" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="mapped-superclass">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines the settings and mappings for a mapped
+ superclass. Is allowed to be sparsely populated and used
+ in conjunction with the annotations. Alternatively, the
+ metadata-complete attribute can be used to indicate that
+ no annotations are to be processed If this is the case
+ then the defaulting rules will be recursively applied.
+ @Target(TYPE) @Retention(RUNTIME) public @interface
+ MappedSuperclass{}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="id-class" type="orm:id-class"
+ minOccurs="0" />
+ <xsd:element name="exclude-default-listeners"
+ type="orm:emptyType" minOccurs="0" />
+ <xsd:element name="exclude-superclass-listeners"
+ type="orm:emptyType" minOccurs="0" />
+ <xsd:element name="entity-listeners"
+ type="orm:entity-listeners" minOccurs="0" />
+ <xsd:element name="pre-persist" type="orm:pre-persist"
+ minOccurs="0" />
+ <xsd:element name="post-persist" type="orm:post-persist"
+ minOccurs="0" />
+ <xsd:element name="pre-remove" type="orm:pre-remove"
+ minOccurs="0" />
+ <xsd:element name="post-remove" type="orm:post-remove"
+ minOccurs="0" />
+ <xsd:element name="pre-update" type="orm:pre-update"
+ minOccurs="0" />
+ <xsd:element name="post-update" type="orm:post-update"
+ minOccurs="0" />
+ <xsd:element name="post-load" type="orm:post-load"
+ minOccurs="0" />
+ <xsd:element name="attributes" type="orm:attributes"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="class" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="metadata-complete" type="xsd:boolean" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="named-native-query">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ NamedNativeQuery { String name(); String query();
+ QueryHint[] hints() default {}; Class resultClass()
+ default void.class; String resultSetMapping() default
+ ""; //named SqlResultSetMapping }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="query" type="xsd:string" />
+ <xsd:element name="hint" type="orm:query-hint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="result-class" type="xsd:string" />
+ <xsd:attribute name="result-set-mapping" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="named-query">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ NamedQuery { String name(); String query(); QueryHint[]
+ hints() default {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="query" type="xsd:string" />
+ <xsd:element name="hint" type="orm:query-hint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="one-to-many">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface OneToMany { Class targetEntity() default
+ void.class; CascadeType[] cascade() default {};
+ FetchType fetch() default LAZY; String mappedBy()
+ default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:element name="order-by" type="orm:order-by"
+ minOccurs="0" />
+ <xsd:element name="order-column" type="orm:order-column"
+ minOccurs="0" />
+ </xsd:choice>
+ <xsd:choice>
+ <xsd:element name="map-key" type="orm:map-key"
+ minOccurs="0" />
+ <xsd:sequence>
+ <xsd:element name="map-key-class"
+ type="orm:map-key-class" minOccurs="0" />
+ <xsd:choice>
+ <xsd:element name="map-key-column"
+ type="orm:map-key-column" minOccurs="0" />
+ <xsd:element name="map-key-join-column"
+ type="orm:map-key-join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:choice>
+ <xsd:choice>
+ <xsd:element name="join-table" type="orm:join-table"
+ minOccurs="0" />
+ <xsd:element name="join-column" type="orm:join-column"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:choice>
+ <xsd:element name="cascade" type="orm:cascade-type"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="target-entity" type="xsd:string" />
+ <xsd:attribute name="fetch" type="orm:fetch-type" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="mapped-by" type="xsd:string" />
+ <xsd:attribute name="orphan-removal" type="xsd:boolean" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="one-to-one">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface OneToOne { Class targetEntity() default
+ void.class; CascadeType[] cascade() default {};
+ FetchType fetch() default EAGER; boolean optional()
+ default true; String mappedBy() default ""; boolean
+ orphanRemoval() default false; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:element name="primary-key-join-column"
+ type="orm:primary-key-join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="join-column" type="orm:join-column"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="join-table" type="orm:join-table"
+ minOccurs="0" />
+ </xsd:choice>
+ <xsd:element name="cascade" type="orm:cascade-type"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="target-entity" type="xsd:string" />
+ <xsd:attribute name="fetch" type="orm:fetch-type" />
+ <xsd:attribute name="optional" type="xsd:boolean" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ <xsd:attribute name="mapped-by" type="xsd:string" />
+ <xsd:attribute name="orphan-removal" type="xsd:boolean" />
+ <xsd:attribute name="mapped-by-id" type="xsd:string" />
+ <xsd:attribute name="id" type="xsd:boolean" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="order-by">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface OrderBy { String value() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="order-column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface OrderColumn { String name() default "";
+ boolean nullable() default true; boolean insertable()
+ default true; boolean updatable() default true; String
+ columnDefinition() default ""; boolean contiguous()
+ default true; int base() default 0; String table()
+ default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="nullable" type="xsd:boolean" />
+ <xsd:attribute name="insertable" type="xsd:boolean" />
+ <xsd:attribute name="updatable" type="xsd:boolean" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ <xsd:attribute name="contiguous" type="xsd:boolean" />
+ <xsd:attribute name="base" type="xsd:int" />
+ <xsd:attribute name="table" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="post-load">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PostLoad {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="post-persist">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PostPersist {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="post-remove">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PostRemove {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="post-update">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PostUpdate {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="pre-persist">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PrePersist {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="pre-remove">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PreRemove {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="pre-update">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD}) @Retention(RUNTIME) public @interface
+ PreUpdate {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="method-name" type="xsd:string"
+ use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="primary-key-join-column">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+ public @interface PrimaryKeyJoinColumn { String name()
+ default ""; String referencedColumnName() default "";
+ String columnDefinition() default ""; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="referenced-column-name" type="xsd:string" />
+ <xsd:attribute name="column-definition" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="query-hint">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({}) @Retention(RUNTIME) public @interface
+ QueryHint { String name(); String value(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="value" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="secondary-table">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ SecondaryTable { String name(); String catalog() default
+ ""; String schema() default ""; PrimaryKeyJoinColumn[]
+ pkJoinColumns() default {}; UniqueConstraint[]
+ uniqueConstraints() default {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="primary-key-join-column"
+ type="orm:primary-key-join-column" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xsd:element name="unique-constraint"
+ type="orm:unique-constraint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="catalog" type="xsd:string" />
+ <xsd:attribute name="schema" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="sequence-generator">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+ public @interface SequenceGenerator { String name();
+ String sequenceName() default ""; String catalog()
+ default ""; String schema() default ""; int
+ initialValue() default 1; int allocationSize() default
+ 50; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="sequence-name" type="xsd:string" />
+ <xsd:attribute name="catalog" type="xsd:string" />
+ <xsd:attribute name="schema" type="xsd:string" />
+ <xsd:attribute name="initial-value" type="xsd:int" />
+ <xsd:attribute name="allocation-size" type="xsd:int" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="sql-result-set-mapping">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ SqlResultSetMapping { String name(); EntityResult[]
+ entities() default {}; ColumnResult[] columns() default
+ {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="entity-result" type="orm:entity-result"
+ minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element name="column-result" type="orm:column-result"
+ minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="table">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE}) @Retention(RUNTIME) public @interface
+ Table { String name() default ""; String catalog()
+ default ""; String schema() default "";
+ UniqueConstraint[] uniqueConstraints() default {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="unique-constraint"
+ type="orm:unique-constraint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="catalog" type="xsd:string" />
+ <xsd:attribute name="schema" type="xsd:string" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="table-generator">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+ public @interface TableGenerator { String name(); String
+ table() default ""; String catalog() default ""; String
+ schema() default ""; String pkColumnName() default "";
+ String valueColumnName() default ""; String
+ pkColumnValue() default ""; int initialValue() default
+ 0; int allocationSize() default 50; UniqueConstraint[]
+ uniqueConstraints() default {}; }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string"
+ minOccurs="0" />
+ <xsd:element name="unique-constraint"
+ type="orm:unique-constraint" minOccurs="0"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="table" type="xsd:string" />
+ <xsd:attribute name="catalog" type="xsd:string" />
+ <xsd:attribute name="schema" type="xsd:string" />
+ <xsd:attribute name="pk-column-name" type="xsd:string" />
+ <xsd:attribute name="value-column-name" type="xsd:string" />
+ <xsd:attribute name="pk-column-value" type="xsd:string" />
+ <xsd:attribute name="initial-value" type="xsd:int" />
+ <xsd:attribute name="allocation-size" type="xsd:int" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="temporal">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Temporal { TemporalType value(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="orm:temporal-type" />
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="temporal-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum TemporalType { DATE, // java.sql.Date TIME,
+ // java.sql.Time TIMESTAMP // java.sql.Timestamp }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="DATE" />
+ <xsd:enumeration value="TIME" />
+ <xsd:enumeration value="TIMESTAMP" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="transient">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Transient {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="unique-constraint">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({}) @Retention(RUNTIME) public @interface
+ UniqueConstraint { String[] columnNames(); }
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="column-name" type="xsd:string"
+ maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <!-- **************************************************** -->
+ <xsd:complexType name="version">
+ <xsd:annotation>
+ <xsd:documentation>
+ @Target({METHOD, FIELD}) @Retention(RUNTIME) public
+ @interface Version {}
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="column" type="orm:column" minOccurs="0" />
+ <xsd:element name="temporal" type="orm:temporal"
+ minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="access" type="orm:access-type" />
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Added: jpamodelgen/trunk/pom.xml
===================================================================
--- jpamodelgen/trunk/pom.xml (rev 0)
+++ jpamodelgen/trunk/pom.xml 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,224 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodel-generator-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Hibernate JPA Model Generator Parent</name>
+
+ <description>
+ Hibernate Annotation Processor to cenerate metadata model for JPA2 typesafe queries
+ </description>
+
+ <developers>
+ <developer>
+ <id>hardy.ferentschik</id>
+ <name>Hardy Ferentschik</name>
+ <email>hferents at redhat.com</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ <url>http://in.relation.to/Bloggers/Hardy</url>
+ </developer>
+ </developers>
+
+ <mailingLists>
+ <mailingList>
+ <name>hibernate-dev</name>
+ <post>hibernate-dev at lists.jboss.org</post>
+ </mailingList>
+ </mailingLists>
+
+ <modules>
+ <module>generator</module>
+ <module>test</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0.Beta2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.8</version>
+ <classifier>jdk15</classifier>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
+ </extensions>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Implementation-Title>${pom.artifactId}</Implementation-Title>
+ <Implementation-Version>${pom.version}</Implementation-Version>
+ <Implementation-Vendor>${pom.groupId}</Implementation-Vendor>
+ <Implementation-Vendor-Id>${pom.groupId}</Implementation-Vendor-Id>
+ <Implementation-URL>${pom.url}</Implementation-URL>
+ <Specification-Title>JPA2 Model Generator</Specification-Title>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-9</version>
+ <configuration>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
+ <remoteTagging>true</remoteTagging>
+ <goals>package deploy</goals>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <!--ciManagement>
+ <system>Hudson</system>
+ <url></url>
+ </ciManagement>
+
+ <issueManagement>
+ <system>JIRA</system>
+ <url>http://opensource.atlassian.com/projects/hibernate/browse/HV</url>
+ </issueManagement-->
+
+ <inceptionYear>2009</inceptionYear>
+
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>license.txt</url>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/hibernate/jpamodelgen/trunk</connection>
+ <url>http://fisheye.jboss.org/browse/Hibernate/jpamodelgen/trunk</url>
+ </scm>
+
+ <distributionManagement>
+ <repository>
+ <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
+ <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
+ <!-- todo : replace this with direct svn access once the svnkit providers are available -->
+ <id>repository.jboss.org</id>
+ <url>file://${maven.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.0.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <id>html</id>
+ <configuration>
+ <tags>
+ <tag>
+ <name>todo</name>
+ <placement>a</placement>
+ <head>ToDo:</head>
+ </tag>
+ </tags>
+ </configuration>
+ <reports>
+ <report>javadoc</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jxr-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clover-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>changelog-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>changes-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Added: jpamodelgen/trunk/test/pom.xml
===================================================================
--- jpamodelgen/trunk/test/pom.xml (rev 0)
+++ jpamodelgen/trunk/test/pom.xml 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,126 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodel-generator-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodel-generator-test</artifactId>
+ <name>Hibernate JPA Model Generator Test</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodel-generator</artifactId>
+ <version>${version}</version>
+ </dependency>
+
+ <!--
+ Test dependencies
+ -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>test</defaultGoal>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>process__annotations</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <property name="target.dir" value="target/generated-sources"/>
+ <mkdir dir="${target.dir}"/>
+ <javac srcdir="src/main/java" destdir="${target.dir}" failonerror="false">
+ <compilerarg value="-proc:only"/>
+ <classpath>
+ <path refid="maven.compile.classpath"/>
+ </classpath>
+ </javac>
+ </tasks>
+ <sourceRoot>generate</sourceRoot>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-test-report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report-only</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
+ <outputName>test-report</outputName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: jpamodelgen/trunk/test/src/main/java/Test.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/Test.java (rev 0)
+++ jpamodelgen/trunk/test/src/main/java/Test.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,143 @@
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Set;
+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.QueryBuilder;
+import javax.persistence.criteria.Root;
+
+import model.Item;
+import model.Order;
+import model.Product;
+import model.metamodel.Item_;
+import model.metamodel.Order_;
+import model.metamodel.Product_;
+import model.metamodel.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.
+ */
+public class Test {
+
+ QueryBuilder qb;
+
+ public void test() {
+ CriteriaQuery q = qb.create();
+
+ 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(order, product)
+ .where( qb.and( qb.gt(price, 100.00), qb.not(filled) ) )
+ .order( qb.asc(price), qb.desc(date) );
+ }
+
+ public void testUntypesafe() {
+ CriteriaQuery q = qb.create();
+
+ 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(order, product)
+ .where( qb.and( qb.gt(price, 100.00), qb.not(filled) ) )
+ .order( qb.asc(price), qb.desc(date) );
+ }
+
+ /**
+ * Navigation by joining
+ */
+ public void test2() {
+ CriteriaQuery q = qb.create();
+
+ 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 q = qb.create();
+
+ Root<Item> item = q.from(Item.class);
+ Join<Item, Order> io = item.join(Item_.namedOrders);
+
+ }
+
+ /**
+ * Navigation by compound Path
+ */
+ public void test3() {
+ CriteriaQuery q = qb.create();
+
+ 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 q = qb.create();
+
+ 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.jpa.criteria.Order o = qb.asc(n);
+ javax.jpa.criteria.Order p = qb.ascending(s);
+ }*/
+
+}
Added: jpamodelgen/trunk/test/src/main/java/model/Item.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/model/Item.java (rev 0)
+++ jpamodelgen/trunk/test/src/main/java/model/Item.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,63 @@
+package model;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+ at Entity
+public class Item {
+
+ long _id;
+
+ int _quantity;
+
+ Product _product;
+
+ Order _order;
+
+ @Id
+ public long getId() {
+ return _id;
+ }
+
+ public void setId(long id) {
+ this._id = id;
+ }
+
+ public int getQuantity() {
+ return _quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this._quantity = quantity;
+ }
+
+ @ManyToOne
+ public Product getProduct() {
+ return _product;
+ }
+
+ public void setProduct(Product product) {
+ this._product = product;
+ }
+
+ @ManyToOne
+ public Order getOrder() {
+ return _order;
+ }
+
+ public void setOrder(Order order) {
+ this._order = order;
+ }
+
+ @OneToMany
+ public Map<String, Order> getNamedOrders() {
+ return null;
+ }
+
+
+}
Added: jpamodelgen/trunk/test/src/main/java/model/Order.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/model/Order.java (rev 0)
+++ jpamodelgen/trunk/test/src/main/java/model/Order.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,28 @@
+package model;
+
+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;
+
+ at Entity
+public class Order {
+
+ @Id
+ long id;
+
+ @OneToMany
+ Set<Item> items;
+
+ boolean filled;
+ Date date;
+
+ @OneToMany
+ List<String> notes;
+
+ @ManyToOne
+ Shop shop;
+}
Added: jpamodelgen/trunk/test/src/main/java/model/Product.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/model/Product.java (rev 0)
+++ jpamodelgen/trunk/test/src/main/java/model/Product.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,27 @@
+package model;
+
+import java.math.BigDecimal;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+ at Entity
+public class Product {
+
+ @Id
+ long id;
+
+ int test;
+
+ String description;
+ BigDecimal price;
+
+ @ManyToOne
+ Shop shop;
+
+ @OneToMany
+ Set<Item> items;
+}
Added: jpamodelgen/trunk/test/src/main/java/model/Shop.java
===================================================================
--- jpamodelgen/trunk/test/src/main/java/model/Shop.java (rev 0)
+++ jpamodelgen/trunk/test/src/main/java/model/Shop.java 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,12 @@
+package model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+ at Entity
+public class Shop {
+ @Id
+ long id;
+ String name;
+}
+
\ No newline at end of file
Added: jpamodelgen/trunk/test/src/main/resources/META-INF/orm.xml
===================================================================
--- jpamodelgen/trunk/test/src/main/resources/META-INF/orm.xml (rev 0)
+++ jpamodelgen/trunk/test/src/main/resources/META-INF/orm.xml 2009-07-07 09:04:46 UTC (rev 17010)
@@ -0,0 +1,37 @@
+<?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"
+ >
+ <!-- careful old JPA1 schema -->
+ <package>model</package> <!-- default package -->
+ <entity class="Order" access="FIELD" metadata-complete="true"> <!--means ignore annotations-->
+ <attributes>
+ <id name="id">
+ <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/>
+ </cascade>
+ </one-to-many>
+ <many-to-one name="shop"/>
+ <element-collection name="notes"/> <!-- new in JPA 2 -->
+ </attributes>
+ </entity>
+</entity-mappings>
+
+
+ <!--
+public class Order {
+ long id;
+ Set<Item> items;
+ boolean filled;
+ Date date;
+ List<String> notes;
+ Shop shop;
+} -->
\ No newline at end of file
More information about the hibernate-commits
mailing list