JBoss Tools SVN: r13098 - in workspace/max/jpaap: javax.persistence/src and 18 other directories.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-01-16 12:44:28 -0500 (Fri, 16 Jan 2009)
New Revision: 13098
Added:
workspace/max/jpaap/javax.persistence/src/
workspace/max/jpaap/javax.persistence/src/javax/
workspace/max/jpaap/javax.persistence/src/javax/jpa/
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/
workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java
workspace/max/jpaap/jpaap/src/
workspace/max/jpaap/jpaap/src/META-INF/
workspace/max/jpaap/jpaap/src/META-INF/services/
workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor
workspace/max/jpaap/jpaap/src/org/
workspace/max/jpaap/jpaap/src/org/jboss/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java
workspace/max/jpaap/test/src/
workspace/max/jpaap/test/src/Test.java
workspace/max/jpaap/test/src/model/
workspace/max/jpaap/test/src/model/Item.java
workspace/max/jpaap/test/src/model/Order.java
workspace/max/jpaap/test/src/model/Product.java
workspace/max/jpaap/test/src/model/Shop.java
Modified:
workspace/max/jpaap/jpaap/
workspace/max/jpaap/test/
workspace/max/jpaap/test/test jpa-build.xml.launch
Log:
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.AbstractCollection;
+
+/**
+ * A join to a collection
+ */
+public interface AbstractCollectionJoin<Z, C, E>
+ extends Join<Z, E> {
+ AbstractCollection<? super Z, C, E> getModel();
+
+ //TODO: do we need these????
+ /*
+ Predicate isEmpty();
+ Predicate isNotEmpty();
+
+ Expression<Integer> size();
+
+ Predicate isMember(E elem);
+ Predicate isNotMember(E elem);
+
+ Predicate isMember(Expression<E> elem);
+ Predicate isNotMember(Expression<E> elem);
+ */
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,36 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.jpa.metamodel.Entity;
+
+/**
+ * All queries have:
+ * a set of root bound entities (which may in turn own joins)
+ * a conjunction of restrictions
+ * an ordered list of orders
+ */
+public interface AbstractQuery {
+
+ <X> Root<X> addRoot(Entity<X> entity);
+ <X> Root<X> addRoot(Class<X> entityClass);
+ Set<Root<?>> getRoots();
+
+ AbstractQuery where(Expression<Boolean> restriction);
+ AbstractQuery where(Predicate... restrictions);
+ AbstractQuery group(Expression<?>... grouping);
+ AbstractQuery having(Expression<Boolean> restriction);
+ AbstractQuery having(Predicate... restrictions);
+ AbstractQuery order(Order... o);
+ AbstractQuery distinct(boolean distinct);
+
+ List<Order> getOrderList();
+ List<Expression<?>> getGroupList();
+ Predicate getRestriction();
+ Predicate getGroupRestriction();
+ boolean isDistinct();
+
+ <U> Subquery<U> subquery(Class<U> type);
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+import java.util.Collection;
+
+public interface CollectionJoin<Z, E>
+ extends AbstractCollectionJoin<Z, Collection<E>, E> {
+ javax.jpa.metamodel.Collection<? super Z, E> getModel();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+public interface Expression<T> extends Selection {
+ Class<T> getJavaType();
+
+ Predicate isNull();
+ Predicate isNotNull();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,12 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Member;
+
+/**
+ * Represents a fetched association or attribute
+ */
+public interface Fetch<Z, X> extends FetchParent<Z, X> {
+ Member<? extends Z, X> getMember();
+ FetchParent<?, Z> getParent();
+ JoinType getJoinType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.AbstractCollection;
+import javax.jpa.metamodel.Attribute;
+
+/**
+ * Represents an element of the from clause which may
+ * function as the parent of Fetches.
+ */
+public interface FetchParent<Z, X> {
+ java.util.Set<Fetch<X, ?>> getFetches();
+
+ <Y> Fetch<X, Y> fetch(Attribute<? super X, Y> assoc);
+ <Y> Fetch<X, Y> fetch(AbstractCollection<? super X, ?, Y> assoc);
+
+ <Y> Fetch<X, Y> fetch(Attribute<? super X, Y> assoc, JoinType jt);
+ <Y> Fetch<X, Y> fetch(AbstractCollection<? super X, ?, Y> assoc, JoinType jt);
+
+ //Untypesafe:
+
+ <Y> Fetch<X, Y> fetch(String assocName);
+ <Y> Fetch<X, Y> fetch(String assocName, JoinType jt);
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,47 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Collection;
+import javax.jpa.metamodel.List;
+import javax.jpa.metamodel.Map;
+import javax.jpa.metamodel.Set;
+
+/**
+ * Represents a bound type, usually an entity that appears in
+ * the from clause, but may also be an embeddable belonging to
+ * an entity in the from clause. A factory for Joins of associations,
+ * embeddables and collections belonging to the type, and for Paths
+ * of attributes belonging to the type.
+ */
+public interface From<Z, X> extends Path<X>, FetchParent<Z, X> {
+ java.util.Set<Join<X, ?>> getJoins();
+
+ <Y> Join<X, Y> join(Attribute<? super X, Y> attribute);
+ <Y> Join<X, Y> join(Attribute<? super X, Y> attribute, JoinType jt);
+
+ <Y> CollectionJoin<X, Y> join(Collection<? super X, Y> collection);
+ <Y> SetJoin<X, Y> join(Set<? super X, Y> set);
+ <Y> ListJoin<X, Y> join(List<? super X, Y> list);
+ <K, V> MapJoin<X, K, V> join(Map<? super X, K, V> map);
+
+ <Y> CollectionJoin<X, Y> join(Collection<? super X, Y> collection, JoinType jt);
+ <Y> SetJoin<X, Y> join(Set<? super X, Y> set, JoinType jt);
+ <Y> ListJoin<X, Y> join(List<? super X, Y> list, JoinType jt);
+ <K, V> MapJoin<X, K, V> join(Map<? super X, K, V> map, JoinType jt);
+
+ Expression<Class<? extends X>> type();
+
+ //Untypesafe:
+
+ <W, Y> Join<W, Y> join(String attributeName);
+ <W, Y> CollectionJoin<W, Y> joinCollection(String attributeName);
+ <W, Y> SetJoin<W, Y> joinSet(String attributeName);
+ <W, Y> ListJoin<W, Y> joinList(String attributeName);
+ <W, K, V> MapJoin<W, K, V> joinMap(String attributeName);
+
+ <W, Y> Join<W, Y> join(String attributeName, JoinType jt);
+ <W, Y> CollectionJoin<W, Y> joinCollection(String attributeName, JoinType jt);
+ <W, Y> SetJoin<W, Y> joinSet(String attributeName, JoinType jt);
+ <W, Y> ListJoin<W, Y> joinList(String attributeName, JoinType jt);
+ <W, K, V> MapJoin<W, K, V> joinMap(String attributeName, JoinType jt);
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,12 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Member;
+
+/**
+ * A join to an entity or embeddable type
+ */
+public interface Join<Z, X> extends From<Z, X> {
+ Member<? extends Z, X> getMember();
+ From<?, Z> getParent();
+ JoinType getJoinType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+/**
+ * The three types of joins
+ */
+public enum JoinType {
+ inner, left, right
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,9 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+
+public interface ListJoin<Z, E>
+ extends AbstractCollectionJoin<Z, List<E>, E> {
+ javax.jpa.metamodel.List<? super Z, E> getModel();
+ Expression<Integer> index();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,13 @@
+package javax.jpa.criteria;
+
+import java.util.Map;
+
+public interface MapJoin<Z, K, V>
+ extends AbstractCollectionJoin<Z, Map<K, V>, V> {
+ javax.jpa.metamodel.Map<? super Z, K, V> getModel();
+ Join<Map<K, V>, K> joinKey();
+ Join<Map<K, V>, K> joinKey(JoinType jt);
+ Path<K> key();
+ Path<V> value(); //Unnecessary - just returns this
+ Expression<Map.Entry<K, V>> entry();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,10 @@
+package javax.jpa.criteria;
+
+/**
+ * An object that imposes an order upon the query results
+ */
+public interface Order {
+ void reverse();
+ boolean isAscending();
+ <T extends Comparable<T>> Expression<T> getExpression();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.AbstractCollection;
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Bindable;
+import javax.jpa.metamodel.Map;
+
+/**
+ * Represents a simple or compound attribute path from a
+ * bound type or collection, and is a "primitive" expression.
+ */
+public interface Path<X> extends Expression<X> {
+ Bindable<X> getModel(); //TODO: what does this return for a collection key, value? null?
+ Path<?> getParentPath();
+
+ <Y> Path<Y> get(Attribute<? super X, Y> model);
+ <E, C extends java.util.Collection<E>> Expression<C> get(AbstractCollection<X, C, E> collection);
+ <K, V, M extends java.util.Map<K, V>> Expression<M> get(Map<X, K, V> collection);
+
+ //Untypesafe:
+
+ <Y> Path<Y> get(String attName);
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,19 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+
+/**
+ * A conjunction or disjunction of restrictions
+ */
+public interface Predicate extends Expression<Boolean> {
+
+ public static enum BooleanOperator {
+ and, or
+ }
+
+ BooleanOperator getOperator();
+ boolean isNegated();
+ List<Expression<Boolean>> getExpressions();
+ Predicate add(Expression<Boolean> s);
+ Predicate negate();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+
+
+/**
+ * A top-level query has an ordered list of selections
+ */
+public interface Query extends AbstractQuery {
+
+ Query select(Selection... selections);
+
+ //override the return type only:
+ Query where(Expression<Boolean> restriction);
+ Query where(Predicate... restrictions);
+ Query group(Expression<?>... grouping);
+ Query having(Expression<Boolean> restriction);
+ Query order(Order... o);
+ Query distinct(boolean distinct);
+
+ List<Selection> getSelectionList();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,244 @@
+package javax.jpa.criteria;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Factory object for queries, orders, restrictions, expressions.
+ * The factory methods are all completely typesafe. Note that
+ * Predicate is used instead of Expression<Boolean> in this
+ * API in order to work around the fact that Java generics are
+ * not compatible with varags.
+ */
+public interface QueryBuilder {
+ Query create();
+
+ //select new Foo(...) equivalent:
+
+ <Y> Selection select(Class<Y> result, Selection... selections);
+
+ //ordering:
+ //unfortunately, Number does not implement Comparable :-(
+
+ <Y extends Comparable<Y>> Order ascending(Expression<? extends Y> x);
+ <Y extends Comparable<Y>> Order descending(Expression<? extends Y> x);
+
+ Order asc(Expression<? extends Number> x);
+ Order desc(Expression<? extends Number> x);
+
+ //aggregate functions:
+
+ <N extends Number> Expression<N> avg(Expression<N> x);
+ <N extends Number> Expression<N> sum(Expression<N> x);
+ <N extends Number> Expression<N> max(Expression<N> x);
+ <N extends Number> Expression<N> min(Expression<N> x);
+
+ Expression<Integer> count(Expression<?> x);
+ Expression<Integer> countDistinct(Expression<?> x);
+
+ //subqueries:
+
+ Predicate exists(Subquery<?> subquery);
+ <Y> Expression<Y> all(Subquery<Y> subquery);
+ <Y> Expression<Y> none(Subquery<Y> subquery);
+ <Y> Expression<Y> some(Subquery<Y> subquery);
+
+ //boolean functions:
+
+ Predicate and(Expression<Boolean> x, Expression<Boolean> y);
+ Predicate or(Expression<Boolean> x, Expression<Boolean> y);
+ Predicate and(Predicate... restrictions);
+ Predicate or(Predicate... restrictions);
+ Predicate not(Expression<Boolean> restriction);
+
+ Predicate conjunction();
+ Predicate disjunction();
+
+ //turn Expression<Boolean> into a Predicate
+ //useful for use with varargs methods
+ Predicate isTrue(Expression<Boolean> x);
+ Predicate isFalse(Expression<Boolean> x);
+
+ //equality:
+
+ Predicate equal(Expression<?> x, Expression<?> y);
+ Predicate notEqual(Expression<?> x, Expression<?> y);
+
+ Predicate equal(Expression<?> x, Object y);
+ Predicate notEqual(Expression<?> x, Object y);
+
+ //Predicate equal(Expression<?> x, Expression<?> y);
+ //Predicate notEqual(Expression<?> x, Expression<?> y);
+ //<Y> Predicate equal(Expression<Y> x, Y y);
+ //<Y> Predicate notEqual(Expression<Y> x, Y y);
+ //Predicate eq(Expression<? extends Number> x, Expression<? extends Number> y);
+ //Predicate ne(Expression<? extends Number> x, Expression<? extends Number> y);
+ //Predicate eq(Expression<? extends Number> x, Number y);
+ //Predicate ne(Expression<? extends Number> x, Number y);
+
+ //comparisons for generic (non-numeric) operands:
+
+ <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Expression<? extends Y> x, Expression<? extends Y> y);
+
+ <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Y x, Y y);
+
+ //comparisons for numeric operands:
+
+ Predicate gt(Expression<? extends Number> x, Expression<? extends Number> y);
+ Predicate lt(Expression<? extends Number> x, Expression<? extends Number> y);
+ Predicate ge(Expression<? extends Number> x, Expression<? extends Number> y);
+ Predicate le(Expression<? extends Number> x, Expression<? extends Number> y);
+
+ Predicate gt(Expression<? extends Number> x, Number y);
+ Predicate lt(Expression<? extends Number> x, Number y);
+ Predicate ge(Expression<? extends Number> x, Number y);
+ Predicate le(Expression<? extends Number> x, Number y);
+
+ //coalesce, nullif:
+
+ <Y> Expression<Y> coalesce(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y> Expression<Y> coalesce(Expression<? extends Y> x, Y y);
+
+ <Y> Expression<Y> nullif(Expression<Y> x, Expression<?> y);
+ <Y> Expression<Y> nullif(Expression<Y> x, Object y);
+
+ //numerical operations:
+
+ <N extends Number> Expression<N> neg(Expression<N> x);
+ <N extends Number> Expression<N> abs(Expression<N> x);
+
+ //TODO: support builder pattern for sums, products
+ <N extends Number> Expression<N> sum(Expression<? extends N> x, Expression<? extends N> y);
+ <N extends Number> Expression<N> prod(Expression<? extends N> x, Expression<? extends N> y);
+ <N extends Number> Expression<N> diff(Expression<? extends N> x, Expression<? extends N> y);
+ <N extends Number> Expression<N> sum(Expression<? extends N> x, N y);
+ <N extends Number> Expression<N> prod(Expression<? extends N> x, N y);
+ <N extends Number> Expression<N> diff(Expression<? extends N> x, N y);
+ <N extends Number> Expression<N> sum(N x, Expression<? extends N> y);
+ <N extends Number> Expression<N> prod(N x, Expression<? extends N> y);
+ <N extends Number> Expression<N> diff(N x, Expression<? extends N> y);
+
+ Expression<Number> quot(Expression<? extends Number> x, Expression<? extends Number> y);
+ Expression<Number> quot(Expression<? extends Number> x, Number y);
+ Expression<Number> quot(Number x, Expression<? extends Number> y);
+
+ Expression<Integer> mod(Expression<Integer> x, Expression<Integer> y);
+ Expression<Integer> mod(Expression<Integer> x, Integer y);
+ Expression<Integer> mod(Integer x, Expression<Integer> y);
+
+ Expression<Double> sqrt(Expression<? extends Number> x);
+
+ //typecasts:
+
+ Expression<Long> toLong(Expression<? extends Number> number);
+ Expression<Integer> toInteger(Expression<? extends Number> number);
+ Expression<Float> toFloat(Expression<? extends Number> number);
+ Expression<Double> toDouble(Expression<? extends Number> number);
+ Expression<BigDecimal> toBigDecimal(Expression<? extends Number> number);
+ Expression<BigInteger> toBigInteger(Expression<? extends Number> number);
+
+ Expression<String> toString(Expression<Character> character);
+
+ //almost always unnecessary:
+ <T> Expression<T> literal(T value);
+
+ //collection operations:
+
+ <C extends Collection<?>> Predicate isEmpty(Expression<C> collection);
+ <C extends Collection<?>> Predicate isNotEmpty(Expression<C> collection);
+
+ <C extends Collection<?>> Expression<Integer> size(C collection);
+
+ <E, C extends Collection<E>> Predicate isMember(E elem, C collection);
+ <E, C extends Collection<E>> Predicate isNotMember(E elem, C collection);
+
+ <E, C extends Collection<E>> Predicate isMember(Expression<E> elem, C collection);
+ <E, C extends Collection<E>> Predicate isNotMember(Expression<E> elem, C collection);
+
+ //get the values and keys collections of the Map, which may then
+ //be passed to size(), isMember(), isEmpty(), etc
+ <V, M extends Map<?, V>> Expression<Collection<V>> values(M map);
+ <K, M extends Map<K, ?>> Expression<Set<K>> keySet(M map);
+
+ //string functions:
+
+ public static enum Trimspec { leading, trailing, both }
+
+ Predicate like(Expression<String> x, Expression<String> pattern);
+ Predicate like(Expression<String> x, String pattern);
+ Predicate notLike(Expression<String> x, Expression<String> pattern);
+ Predicate notLike(Expression<String> x, String pattern);
+
+ Expression<String> concat(Expression<String> x, Expression<String> y);
+ Expression<String> concat(Expression<String> x, String y);
+ Expression<String> concat(String x, Expression<String> y);
+
+ Expression<String> substring(Expression<String> x, Expression<Integer> from);
+ Expression<String> substring(Expression<String> x, int from);
+ Expression<String> substring(Expression<String> x, Expression<Integer> from, Expression<Integer> to);
+ Expression<String> substring(Expression<String> x, int from, int to);
+
+ Expression<String> trim(Expression<Character> t, Expression<String> x);
+ Expression<String> trim(Trimspec ts, Expression<Character> t, Expression<String> x);
+ Expression<String> trim(char t, Expression<String> x);
+ Expression<String> trim(Trimspec ts, char t, Expression<String> x);
+
+ Expression<String> lower(Expression<String> x);
+ Expression<String> upper(Expression<String> x);
+ Expression<Integer> length(Expression<String> x);
+
+ Expression<Integer> locate(Expression<String> x, Expression<String> pattern);
+ Expression<Integer> locate(Expression<String> x, Expression<String> pattern, Expression<Integer> from);
+ Expression<Integer> locate(Expression<String> x, String pattern);
+ Expression<Integer> locate(Expression<String> x, String pattern, int from);
+
+ Expression<java.sql.Date> currentDate();
+ Expression<java.sql.Timestamp> currentTimestamp();
+ Expression<java.sql.Time> currentTime();
+
+ //case/in builders:
+
+ public static interface In<T> extends Expression<Boolean> {
+ Expression<T> getExpression();
+ //TODO: should we restrict the types to T?
+ In<T> value(Object value);
+ In<T> value(Expression<?> value);
+ }
+
+ <T> In<T> in(Expression<T> expression);
+
+ public static interface SimpleCase<C,R> extends Expression<R> {
+ Expression<C> getExpression();
+ SimpleCase<C, R> when(C condition, R result);
+ SimpleCase<C, R> when(C condition, Expression<R> result);
+ }
+
+ public static interface Case<R> extends Expression<R> {
+ Case<R> when(Expression<Boolean> condition, R result);
+ Case<R> when(Expression<Boolean> condition, Expression<R> result);
+ }
+
+ <C, R> SimpleCase<C,R> selectCase(Expression<C> expression);
+ <R> Case<R> selectCase();
+
+ public static interface Coalesce<T> extends Expression<T> {
+ //TODO: should we restrict the types to T?
+ Coalesce<T> value(Object value);
+ Coalesce<T> value(Expression<?> value);
+ }
+
+ <T> Coalesce<T> coalesce();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,10 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Entity;
+
+/**
+ * A root type in the from clause (always an entity type)
+ */
+public interface Root<X> extends From<X, X> {
+ Entity<X> getModel();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+/**
+ * Defines an item that is returned by the query
+ */
+public interface Selection {
+ Class<?> getJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+import java.util.Set;
+
+public interface SetJoin<Z, E>
+ extends AbstractCollectionJoin<Z, Set<E>, E> {
+ javax.jpa.metamodel.Set<? super Z, E> getModel();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,33 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Collection;
+import javax.jpa.metamodel.List;
+import javax.jpa.metamodel.Map;
+import javax.jpa.metamodel.Set;
+
+/**
+ * A top-level query has an expression as its selection
+ */
+public interface Subquery<T> extends AbstractQuery, Expression<T> {
+ AbstractQuery getParent();
+
+ Subquery<T> select(Expression<T> expression);
+
+ //override the return type only:
+ Subquery<T> where(Expression<Boolean> restriction);
+ Subquery<T> where(Predicate... restrictions);
+ Subquery<T> group(Expression<?>... grouping);
+ Subquery<T> having(Expression<Boolean> restriction);
+ Subquery<T> order(Order... o);
+ Subquery<T> distinct(boolean distinct);
+
+ Expression<T> getSelection();
+
+ <Y> Root<Y> correlate(Root<Y> parentRoot);
+ <X, Y> Join<X, Y> correlate(Join<X, Y> parentJoin);
+ <X, Y> CollectionJoin<X, Y> correlate(Collection<X, Y> parentCollection);
+ <X, Y> SetJoin<X, Y> correlate(Set<X, Y> parentSet);
+ <X, Y> ListJoin<X, Y> correlate(List<X, Y> parentList);
+ <X, K, V> MapJoin<X, K, V> correlate(Map<X, K, V> parentMap);
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,20 @@
+package javax.jpa.metamodel;
+
+/**
+ * A persistent collection
+ */
+public interface AbstractCollection<X, C, E>
+ extends Member<X, C>, Bindable<E> {
+
+ public static enum CollectionType {
+ collection, set, list, map
+ }
+
+ public static enum Multiplicity {
+ manyToMany, oneToMany, elements
+ }
+
+ CollectionType getCollectionType();
+ Multiplicity getMultiplicity();
+ Type<E> getElementType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,21 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents a persistent property or field that is not
+ * a collection.
+ * Note that the use of generics allows us to specify both
+ * the type of the attribute, and the type it belongs to.
+ */
+public interface Attribute<X, T>
+ extends Member<X, T>, Bindable<T> {
+
+ public static enum Multiplicity {
+ manyToOne, oneToOne, embedded, basic
+ }
+
+ Multiplicity getMultiplicity();
+ boolean isId();
+ boolean isVersion();
+ boolean isOptional();
+ Type<T> getAttributeType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,6 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents a basic type (including temporal and enumerated types)
+ */
+public interface Basic<X> extends Type<X> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * Any kind of thing that can be bound into the from clause
+ */
+public interface Bindable<T> {
+
+ public static enum BindableType {
+ attribute, collection, managedType
+ }
+
+ BindableType getBindableType();
+
+ Class<T> getJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,9 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents a persistent collection.
+ * Note that the use of generics allows us to specify both
+ * the type of the collection, and the type it belongs to.
+ */
+public interface Collection<X, E>
+ extends AbstractCollection<X, java.util.Collection<E>, E> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface Embeddable<X>
+ extends ManagedType<X> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,9 @@
+package javax.jpa.metamodel;
+
+/**
+ * An entity type
+ */
+public interface Entity<X> extends IdentifiableType<X> {
+ String getName();
+ Class<?> getIdJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents an entity or mapped superclass
+ */
+public interface IdentifiableType<X> extends ManagedType<X> {
+
+ <Y> Attribute<? super X, Y> getId(Class<Y> type);
+ <Y> Attribute<? super X, Y> getVersion(Class<Y> type);
+ <Y> Attribute<X, Y> getDeclaredId(Class<Y> type);
+ <Y> Attribute<X, Y> getDeclaredVersion(Class<Y> type);
+
+ IdentifiableType<? super X> getSupertype();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface List<X, E>
+ extends AbstractCollection<X, java.util.List<E>, E> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,26 @@
+package javax.jpa.metamodel;
+
+/**
+ * An entity, mapped superclass or embeddable type
+ */
+public interface ManagedType<X> extends Type<X>, Bindable<X> {
+
+ <Y> Attribute<? super X, Y> getAttribute(String name, Class<Y> type);
+ <Y> Attribute<X, Y> getDeclaredAttribute(String name, Class<Y> type);
+
+ java.util.Set<Attribute<? super X, ?>> getAttributes();
+ java.util.Set<Attribute<X, ?>> getDeclaredAttributes();
+
+ <E> Collection<? super X, E> getCollection(String name, Class<E> elementType);
+ <E> Set<? super X, E> getSet(String name, Class<E> elementType);
+ <E> List<? super X, E> getList(String name, Class<E> elementType);
+ <K, V> Map<? super X, K, V> getMap(String name, Class<K> keyType, Class<V> valueType);
+ <E> Collection<X, E> getDeclaredColl(String name, Class<E> elementType);
+ <E> Set<X, E> getDeclaredSet(String name, Class<E> elementType);
+ <E> List<X, E> getDeclaredList(String name, Class<E> elementType);
+ <K, V> Map<X, K, V> getDeclaredMap(String name, Class<K> keyType, Class<V> valueType);
+
+ java.util.Set<AbstractCollection<? super X, ?, ?>> getCollections();
+ java.util.Set<AbstractCollection<X, ?, ?>> getDeclaredCollections();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,7 @@
+package javax.jpa.metamodel;
+
+public interface Map<X, K, V>
+ extends AbstractCollection<X, java.util.Map<K, V>, V> {
+ Class<K> getKeyJavaType();
+ Type<K> getKeyType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface MappedSuperclass<X>
+ extends IdentifiableType<X> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * A member of a Java type
+ */
+public interface Member<X, Y> {
+ //String getName(); //TODO: do we need this? the java.lang.reflect.Member has it
+ ManagedType<X> getDeclaringType();
+ Class<Y> getMemberJavaType();
+ java.lang.reflect.Member getJavaMember();
+ boolean isAssociation();
+ boolean isCollection();
+
+ //TODO: fetch type
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,18 @@
+package javax.jpa.metamodel;
+
+/**
+ * Provides access to the metamodel of persistent
+ * entities in the persistence unit. It is better to
+ * access metamodel objects at initialization time
+ * and cache them statically to allow upfront type
+ * validation. However, they may also be accessed at
+ * runtime.
+ */
+public interface Metamodel {
+ <X> Entity<X> entity(Class<X> clazz);
+ <X> ManagedType<X> type(Class<X> clazz);
+ <X> Embeddable<X> embeddable(Class<X> clazz);
+ java.util.Set<ManagedType<?>> getManagedTypes();
+ java.util.Set<Entity<?>> getEntities();
+ java.util.Set<Embeddable<?>> getEmbeddables();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface Set<X, E>
+ extends AbstractCollection<X, java.util.Set<E>, E> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * Any type allowed for a persistent attribute
+ */
+public interface Type<X> {
+
+ public static enum PersistenceType {
+ entity, embeddable, mappedSuperclass, basic
+ }
+
+ PersistenceType getPersistenceType();
+
+ Class<X> getJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,10 @@
+package javax.jpa.metamodel;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface TypesafeMetamodel {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,34 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * This annotation is used to override a many-to-one or one-to-one mapping of property or field for
+ * an entity relationship.
+ * The AssociationOverride annotation may be applied to an entity that extends a mapped superclass
+ * to override a many-to-one or one-to-one mapping defined by the mapped superclass. If the
+ * AssociationOverride annotation is not specified, the join column is mapped the same as in
+ * the original mapping.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AssociationOverride {
+ /**
+ * The name of the relationship property whose mapping is being overridden if property-based
+ * access is being used, or the name of the relationship field if field-based access is used.
+ */
+ String name();
+
+ /**
+ * The join column that is being mapped to the persistent attribute.
+ */
+ JoinColumn[] joinColumns();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,24 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * This annotation is used to override mappings of multiple many-to-one
+ * or one-to-one relationship properties or fields.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AssociationOverrides {
+ /**
+ * Mapping overrides of relationship properties or fields
+ */
+ AssociationOverride[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,34 @@
+//$Id: AttributeOverride.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+
+/**
+ * The AttributeOverride annotation is used to override the mapping of a Basic (whether explicit
+ * or default) property or field or Id property or field.
+ *
+ * The AttributeOverride annotation may be applied to an entity that extends a mapped superclass
+ * or to an embedded field or property to override a basic mapping defined by the mapped superclass
+ * or embeddable class. If the AttributeOverride annotation is not specified, the column is mapped
+ * the same as in the original mapping.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AttributeOverride {
+ /**
+ * The name of the property whose mapping is being overridden if property-based access is being
+ * used, or the name of the field if field-based access is used.
+ */
+ String name();
+ /**
+ * The column that is being mapped to the persistent attribute
+ */
+ Column column();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+//$Id: AttributeOverrides.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+
+/**
+ * Is used to override mappings of multiple properties or fields
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AttributeOverrides {
+ /**
+ * One or more mapping override
+ */
+ AttributeOverride[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,39 @@
+//$Id: Basic.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import static javax.persistence.FetchType.EAGER;
+
+/**
+ * The Basic annotation is the simplest type of mapping to a database column. The Basic
+ * annotation can be applied to a persistent property or instance variable of any of the
+ * following types: Java primitive types, wrappers of the primitive types, String,
+ * java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar,
+ * java.sql.Date, java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], Character[],
+ * enums, and any other type that implements Serializable.
+ *
+ * The use of the Basic annotation is optional for persistent fields and properties of these types.
+
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Basic {
+ /**
+ * Defines whether the value of the field or property should be lazily loaded or must be
+ * eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime
+ * that the value must be eagerly fetched. The LAZY strategy is a hint to the persistence
+ * provider runtime. If not specified, defaults to EAGER.
+ */
+ FetchType fetch() default EAGER;
+ /**
+ * Defines whether the value of the field or property may be null. This is a hint and is
+ * disregarded for primitive types; it may be used in schema generation. If not specified,
+ * defaults to true.
+ */
+ boolean optional() default true;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,32 @@
+//$Id: CascadeType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines the set of cascadable operations that are propagated to the associated entity.
+ * The value cascade=ALL is equivalent to cascade={PERSIST, MERGE, REMOVE, REFRESH}.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum CascadeType {
+ /**
+ * Cascade all operations
+ */
+ ALL,
+ /**
+ * Cascade persist operations
+ */
+ PERSIST,
+ /**
+ * Cascade merge operations
+ */
+ MERGE,
+ /**
+ * Cascade remove operations
+ */
+ REMOVE,
+ /**
+ * Cascade refresh operations
+ */
+ REFRESH
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,65 @@
+//$Id: Column.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Is used to specify a mapped column for a persistent property or field. If no Column annotation is
+ * specified, the default values are applied.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Column {
+ /**
+ * The name of the column. Defaults to the property or field name
+ */
+ String name() default "";
+ /**
+ * Whether the property is a unique key. This is a shortcut for the UniqueConstraint
+ * annotation at the table level and is useful for when the unique key constraint is
+ * only a single field. This constraint applies in addition to any constraint entailed
+ * by primary key mapping and to constraints specified at the table level.
+ */
+ boolean unique() default false;
+ /**
+ * Whether the database column is nullable
+ */
+ boolean nullable() default true;
+ /**
+ * Whether the column is included in SQL INSERT statements generated by the persistence provider.
+ */
+ boolean insertable() default true;
+ /**
+ * Whether the column is included in SQL UPDATE statements generated by the persistence provider.
+ */
+ boolean updatable() default true;
+ /**
+ * The SQL fragment that is used when generating the DDL for the column.
+ * Defaults to the generated SQL to create a column of the inferred type.
+ */
+ String columnDefinition() default "";
+ /**
+ * The name of the table that contains the column. If absent the column is assumed to
+ * be in the primary table.
+ */
+ String table() default "";
+ /**
+ * The column length. (Applies only if a string-valued column is used.)
+ */
+ int length() default 255;
+ /**
+ * The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+ * Value must be set by developer if used when generating the DDL for the column.
+ */
+ int precision() default 0;
+ /**
+ * The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+ */
+ int scale() default 0;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,22 @@
+//$Id: ColumnResult.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * References name of a column in the SELECT clause of a SQL query - i.e.,
+ * column alias, if applicable. Scalar result types can be included in the query
+ * result by specifying this annotation in the metadata.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RetentionPolicy.RUNTIME)
+public @interface ColumnResult {
+ /**
+ * The name of a column in the SELECT clause of a SQL query
+ */
+ String name();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,47 @@
+//$Id: DiscriminatorColumn.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.DiscriminatorType.STRING;
+
+/**
+ * Is used to define the discriminator column for the SINGLE_TABLE and JOINED inheritance
+ * mapping strategies.
+ *
+ * The strategy and the discriminator column are only specified in the root of an entity
+ * class hierarchy or subhierarchy in which a different inheritance strategy is applied
+ *
+ * If the DiscriminatorColumn annotation is missing, and a discriminator column is required,
+ * the name of the discriminator column defaults to "DTYPE" and the discriminator type to
+ * DiscriminatorType.STRING.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface DiscriminatorColumn {
+ /**
+ * The name of column to be used for the discriminator.
+ */
+ String name() default "DTYPE";
+ /**
+ * The type of object/column to use as a class discriminator.
+ * Defaults to DiscriminatorType.STRING
+ */
+ DiscriminatorType discriminatorType() default STRING;
+ /**
+ * The SQL fragment that is used when generating the DDL for the discriminator column.
+ * Defaults to the provider-generated SQL to create a column of the specified
+ * discriminator type.
+ */
+ String columnDefinition() default "";
+ /**
+ * The column length for String-based discriminator types. Ignored for other
+ * discriminator types.
+ */
+ int length() default 31;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+//$Id: DiscriminatorType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines supported types of the discriminator column
+ *
+ * @author Emmanuel Bernard
+ */
+public enum DiscriminatorType {
+ /**
+ * String as the discriminator type
+ */
+ STRING,
+ /**
+ * Single character as the discriminator type
+ */
+ CHAR,
+ /**
+ * Integer as the discriminator type
+ */
+ INTEGER
+};
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,33 @@
+//$Id: DiscriminatorValue.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+
+/**
+ * Is used to specify the value of the discriminator column for entities of the given type.
+ * The DiscriminatorValue annotation can only be specified on a concrete entity class.
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ *
+ * The inheritance strategy and the discriminator column are only specified in the root
+ * of an entity class hierarchy or subhierarchy in which a different inheritance strategy
+ * is applied. The discriminator value, if not defaulted, should be specified for each entity
+ * class in the hierarchy.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface DiscriminatorValue {
+ /**
+ * The value that indicates that the row is an entity of the annotated entity type.
+ *
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ */
+ String value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,22 @@
+//$Id: Embeddable.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB Specification Copyright 2004 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+
+/**
+ * Defines a class whose instances are stored as an intrinsic part of an owning entity and share
+ * the identity of the entity. Each of the persistent properties or fields of the embedded object
+ * is mapped to the database table for the entity. Only Basic, Column, Lob, Temporal, and
+ * Enumerated mapping annotations may portably be used to map the persistent fields or properties
+ * of classes annotated as Embeddable.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface Embeddable {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,18 @@
+//$Id: Embedded.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB Specification Copyright 2004 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Defines a persistent field or property of an entity whose value is an instance of
+ * an embeddable class. The embeddable class must be annotated as Embeddable.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Embedded {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,19 @@
+//$Id: EmbeddedId.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Is applied to a persistent field or property of an entity class or mapped superclass to denote
+ * a composite primary key that is an embeddable class. The embeddable class must be annotated
+ * as Embeddable.
+ *
+ * @author Emmanuel Bernard
+ */
+(a)Target({ElementType.METHOD, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface EmbeddedId {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+//$Id: Entity.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Specifies that the class is an entity. This annotation is applied to the entity class.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface Entity {
+ /**
+ * The name of an entity. Defaults to the unqualified name of the entity class.
+ * This name is used to refer to the entity in queries. The name must not be a
+ * reserved literal in the Java Persistence query language.
+ */
+ String name() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,45 @@
+//$Id: $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when EntityManager.persist(Object) is called and the
+ * entity already exists. The current transaction, if one is active, will be marked for rollback.
+ *
+ * @author Emmanuel Bernard
+ */
+public class EntityExistsException extends PersistenceException {
+ /**
+ * Constructs a new EntityExistsException exception with null as its detail message.
+ */
+ public EntityExistsException() {
+ super();
+ }
+
+ /**
+ * Constructs a new EntityExistsException exception with the specified cause.
+ *
+ * @param cause the cause
+ */
+ public EntityExistsException(Throwable cause) {
+ super( cause );
+ }
+
+ /**
+ * Constructs a new EntityExistsException exception with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public EntityExistsException(String message) {
+ super( message );
+ }
+
+ /**
+ * Constructs a new EntityExistsException exception with the specified detail message and cause.
+ *
+ * @param message the detail message.
+ * @param cause the cause.
+ */
+ public EntityExistsException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Specifies the callback listener classes to be used for an entity or mapped superclass.
+ * This annotation may be applied to an entity class or mapped superclass.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface EntityListeners {
+ /**
+ * The callback listener classes
+ */
+ Class[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,298 @@
+// $Id: EntityManager.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Interface used to interact with the persistence context.
+ *
+ * An EntityManager instance is associated with a persistence context. A persistence context is a set of
+ * entity instances in which for any persistent entity identity there is a unique entity instance.
+ * Within the persistence context, the entity instances and their lifecycle are managed. This interface
+ * defines the methods that are used to interact with the persistence context. The EntityManager API is
+ * used to create and remove persistent entity instances, to find entities by their primary key, and to
+ * query over entities.
+ *
+ * The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit.
+ * A persistence unit defines the set of all classes that are related or grouped by the application, and
+ * which must be colocated in their mapping to a single database.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface EntityManager {
+ /**
+ * Make an entity instance managed and persistent.
+ *
+ * @param entity
+ * @throws EntityExistsException if the entity already exists.
+ * (The EntityExistsException may be thrown when the persist
+ * operation is invoked, or the EntityExistsException or
+ * another PersistenceException may be thrown at commit
+ * time.)
+ * @throws IllegalStateException if this EntityManager has been closed.
+ * @throws IllegalArgumentException if not an entity
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ */
+ public void persist(Object entity);
+
+ /**
+ * Merge the state of the given entity into the
+ * current persistence context.
+ *
+ * @param entity
+ * @return the instance that the state was merged to
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if instance is not an
+ * entity or is a removed entity
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ */
+ public <T> T merge(T entity);
+
+ /**
+ * Remove the entity instance.
+ *
+ * @param entity
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if not an entity
+ * or if a detached entity
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ */
+ public void remove(Object entity);
+
+ /**
+ * Find by primary key.
+ *
+ * @param entityClass
+ * @param primaryKey
+ * @return the found entity instance or null
+ * if the entity does not exist
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if the first argument does
+ * not denote an entity type or the second
+ * argument is not a valid type for that
+ * entity’s primary key
+ */
+ public <T> T find(Class<T> entityClass, Object primaryKey);
+
+ /**
+ * Get an instance, whose state may be lazily fetched.
+ * If the requested instance does not exist in the database,
+ * the EntityNotFoundException is thrown when the instance
+ * state is first accessed. (The persistence provider runtime is
+ * permitted to throw the EntityNotFoundException when
+ * getReference is called.)
+ * The application should not expect that the instance state will
+ * be available upon detachment, unless it was accessed by the
+ * application while the entity manager was open.
+ *
+ * @param entityClass
+ * @param primaryKey
+ * @return the found entity instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if the first argument does
+ * not denote an entity type or the second
+ * argument is not a valid type for that
+ * entity’s primary key
+ * @throws EntityNotFoundException if the entity state
+ * cannot be accessed
+ */
+ public <T> T getReference(Class<T> entityClass, Object primaryKey);
+
+ /**
+ * Synchronize the persistence context to the
+ * underlying database.
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws TransactionRequiredException if there is
+ * no transaction
+ * @throws PersistenceException if the flush fails
+ */
+ public void flush();
+
+ /**
+ * Set the flush mode that applies to all objects contained
+ * in the persistence context.
+ *
+ * @param flushMode
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public void setFlushMode(FlushModeType flushMode);
+
+ /**
+ * Get the flush mode that applies to all objects contained
+ * in the persistence context.
+ *
+ * @return flushMode
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public FlushModeType getFlushMode();
+
+ /**
+ * Set the lock mode for an entity object contained
+ * in the persistence context.
+ *
+ * @param entity
+ * @param lockMode
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws PersistenceException if an unsupported lock call
+ * is made
+ * @throws IllegalArgumentException if the instance is not
+ * an entity or is a detached entity
+ * @throws TransactionRequiredException if there is no
+ * transaction
+ */
+ public void lock(Object entity, LockModeType lockMode);
+
+ /**
+ * Refresh the state of the instance from the database,
+ * overwriting changes made to the entity, if any.
+ *
+ * @param entity
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if not an entity
+ * or entity is not managed
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ * @throws EntityNotFoundException if the entity no longer
+ * exists in the database
+ */
+ public void refresh(Object entity);
+
+ /**
+ * Clear the persistence context, causing all managed
+ * entities to become detached. Changes made to entities that
+ * have not been flushed to the database will not be
+ * persisted.
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public void clear();
+
+ /**
+ * Check if the instance belongs to the current persistence
+ * context.
+ *
+ * @param entity
+ * @return <code>true</code> if the instance belongs to the current persistence context.
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if not an entity
+ */
+ public boolean contains(Object entity);
+
+ /**
+ * Create an instance of Query for executing an
+ * EJB QL statement.
+ *
+ * @param ejbqlString an EJB QL query string
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if query string is not valid
+ */
+ public Query createQuery(String ejbqlString);
+
+ /**
+ * Create an instance of Query for executing a
+ * named query (in EJB QL or native SQL).
+ *
+ * @param name the name of a query defined in metadata
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if a query has not been
+ * defined with the given name
+ */
+ public Query createNamedQuery(String name);
+
+ /**
+ * Create an instance of Query for executing
+ * a native SQL statement, e.g., for update or delete.
+ *
+ * @param sqlString a native SQL query string
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Query createNativeQuery(String sqlString);
+
+ /**
+ * Create an instance of Query for executing
+ * a native SQL query.
+ *
+ * @param sqlString a native SQL query string
+ * @param resultClass the class of the resulting instance(s)
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Query createNativeQuery(String sqlString, Class resultClass);
+
+ /**
+ * Create an instance of Query for executing
+ * a native SQL query.
+ *
+ * @param sqlString a native SQL query string
+ * @param resultSetMapping the name of the result set mapping
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Query createNativeQuery(String sqlString, String resultSetMapping);
+
+ /**
+ * Indicate to the EntityManager that a JTA transaction is
+ * active. This method should be called on a JTA application
+ * managed EntityManager that was created outside the scope
+ * of the active transaction to associate it with the current
+ * JTA transaction.
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws TransactionRequiredException if there is
+ * no transaction.
+ */
+ public void joinTransaction();
+
+ /**
+ * Return the underlying provider object for the EntityManager, if available.
+ * The result of this method is implementation specific
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Object getDelegate();
+
+ /**
+ * Close an application-managed EntityManager.
+ * After the close method has been invoked, all methods
+ * on the EntityManager instance and any Query objects obtained
+ * from it will throw the IllegalStateException except
+ * for getTransaction and isOpen (which will return false).
+ * If this method is called when the EntityManager is
+ * associated with an active transaction, the persistence
+ * context remains managed until the transaction completes.
+ *
+ * @throws IllegalStateException if the EntityManager is container-managed or has been already closed
+ */
+ public void close();
+
+ /**
+ * Determine whether the EntityManager is open.
+ *
+ * @return true until the EntityManager has been closed.
+ */
+ public boolean isOpen();
+
+ /**
+ * Return the resource-level transaction object.
+ * The EntityTransaction instance may be used serially to
+ * begin and commit multiple transactions.
+ *
+ * @return EntityTransaction instance
+ * @throws IllegalStateException if invoked on a JTA
+ * EntityManager.
+ */
+ public EntityTransaction getTransaction();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,49 @@
+//$Id: EntityManagerFactory.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.util.Map;
+
+/**
+ * The EntityManagerFactory interface is used by the application to obtain an
+ * application-managed entity manager. When the application has finished using
+ * the entity manager factory, and/or at application shutdown, the application
+ * should close the entity manager factory. Once an EntityManagerFactory has been
+ * closed, all its entity managers are considered to be in the closed state.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface EntityManagerFactory {
+
+ /**
+ * Create a new EntityManager.
+ * This method returns a new EntityManager instance each time
+ * it is invoked.
+ * The isOpen method will return true on the returned instance.
+ */
+ EntityManager createEntityManager();
+
+ /**
+ * Create a new EntityManager with the specified Map of
+ * properties.
+ * This method returns a new EntityManager instance each time
+ * it is invoked.
+ * The isOpen method will return true on the returned instance.
+ */
+ EntityManager createEntityManager(Map map);
+
+ /**
+ * Close the factory, releasing any resources that it holds.
+ * After a factory instance is closed, all methods invoked on
+ * it will throw an IllegalStateException, except for isOpen,
+ * which will return false. Once an EntityManagerFactory has
+ * been closed, all its entity managers are considered to be
+ * in the closed state.
+ */
+ void close();
+
+ /**
+ * Indicates whether or not this factory is open. Returns
+ * true until a call to close has been made.
+ */
+ public boolean isOpen();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,29 @@
+//$Id: EntityNotFoundException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when an entity reference obtained by
+ * EntityManager.getReference(Class,Object) is accessed but the entity does not exist.
+ * Also thrown when EntityManager.refresh(Object) is called and the object no longer exists
+ * in the database. The current transaction, if one is active, will be marked for rollback.
+ *
+ * @author Gavin King
+ */
+public class EntityNotFoundException extends PersistenceException {
+ /**
+ * Constructs a new EntityNotFoundException exception with null as its detail message.
+ */
+ public EntityNotFoundException() {
+ super();
+ }
+
+ /**
+ * Constructs a new EntityNotFoundException exception with the specified detail message.
+ *
+ * @param message the detail message
+ */
+ public EntityNotFoundException(String message) {
+ super( message );
+ }
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,33 @@
+//$Id: EntityResult.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * References an entity in the SELECT clause of a SQL query. If this annotation is used,
+ * the SQL statement should select all of the columns that are mapped to the entity object.
+ * This should include foreign key columns to related entities. The results obtained when
+ * insufficient data is available are undefined.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RetentionPolicy.RUNTIME)
+public @interface EntityResult {
+ /**
+ * The class of the result
+ */
+ Class entityClass();
+ /**
+ * Maps the columns specified in the SELECT list of the query to the properties or
+ * fields of the entity class.
+ */
+ FieldResult[] fields() default {};
+ /**
+ * Specifies the column name (or alias) of the column in the SELECT list that is used to
+ * determine the type of the entity instance.
+ */
+ String discriminatorColumn() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,60 @@
+//$Id: EntityTransaction.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * The EntityTransaction interface is used to control resource transactions
+ * on resource-local entity managers. The EntityManager.getTransaction()
+ * method returns the EntityTransaction interface.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface EntityTransaction {
+ /**
+ * Start a resource transaction.
+ *
+ * @throws IllegalStateException if isActive() is true.
+ */
+ public void begin();
+
+ /**
+ * Commit the current transaction, writing any unflushed
+ * changes to the database.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ * @throws RollbackException if the commit fails.
+ */
+ public void commit();
+
+ /**
+ * Roll back the current transaction.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ * @throws PersistenceException if an unexpected error
+ * condition is encountered.
+ */
+ public void rollback();
+
+ /**
+ * Mark the current transaction so that the only possible
+ * outcome of the transaction is for the transaction to be
+ * rolled back.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ */
+ public void setRollbackOnly();
+
+ /**
+ * Determine whether the current transaction has been marked
+ * for rollback.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ */
+ public boolean getRollbackOnly();
+
+ /**
+ * Indicate whether a transaction is in progress.
+ * @throws PersistenceException if an unexpected error
+ * condition is encountered.
+ */
+ public boolean isActive();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,19 @@
+//$Id: EnumType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Defines mapping for the enumerated types. The constants of this enumerated type specify how persistent
+ * property or field should be persisted as a enumerated type.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum EnumType {
+ /**
+ * Persist enumerated type property or field as an integer
+ */
+ ORDINAL,
+ /**
+ * Persist enumerated type property or field as a string
+ */
+ STRING
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,24 @@
+//$Id: Enumerated.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+import static javax.persistence.EnumType.*;
+
+/**
+ * Specifies that a persistent property or field should be persisted as a enumerated type.
+ * It may be used in conjunction with the Basic annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Enumerated {
+ /**
+ * The type used in mapping an enum type
+ */
+ EnumType value() default ORDINAL;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,17 @@
+//$Id: ExcludeDefaultListeners.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Specifies that the invocation of default listeners is to be excluded for the entity class
+ * (or mapped superclass) and its subclasses.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface ExcludeDefaultListeners {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,17 @@
+//$Id: ExcludeSuperclassListeners.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+
+/**
+ * Specifies that the invocation of superclass listeners is to be excluded for the
+ * entity class (or mapped superclass) and its subclasses.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface ExcludeSuperclassListeners {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,24 @@
+//$Id: FetchType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines strategies for fetching data from the database.
+ * The EAGER strategy is a requirement on the persistence provider runtime that data must
+ * be eagerly fetched. The LAZY strategy is a hint to the persistence provider runtime that
+ * data should be fetched lazily when it is first accessed. The implementation is permitted to
+ * eagerly fetch data for which the LAZY strategy hint has been specified. In particular, lazy
+ * fetching might only be available for Basic mappings for which property-based access is used.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum FetchType {
+ /**
+ * Defines that data must be lazily fetched
+ */
+ LAZY,
+ /**
+ * Defines that data must be eagerly fetched
+ */
+ EAGER
+};
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+//$Id: FieldResult.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Is used to map the columns specified in the SELECT list of the query to the properties
+ * or fields of the entity class.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RetentionPolicy.RUNTIME)
+public @interface FieldResult {
+ /**
+ * Name of the persistent field or property of the class.
+ */
+ String name();
+ /**
+ * Name of the column in the SELECT clause - i.e., column aliases, if applicable.
+ */
+ String column();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,29 @@
+//$Id: FlushModeType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Flush mode setting.
+ *
+ * When queries are executed within a transaction, if FlushModeType.AUTO is set on the Query object,
+ * or if the flush mode setting for the persistence context is AUTO (the default) and a flush mode
+ * setting has not been specified for the Query object, the persistence provider is responsible for
+ * ensuring that all updates to the state of all entities in the persistence context which could
+ * potentially affect the result of the query are visible to the processing of the query.
+ * The persistence provider implementation may achieve this by flushing those entities to the database
+ * or by some other means. If FlushModeType.COMMIT is set, the effect of updates made to entities in the
+ * persistence context upon queries is unspecified.
+ *
+ * If there is no transaction active, the persistence provider must not flush to the database.
+ *
+ * @author Gavin King
+ */
+public enum FlushModeType {
+ /**
+ * Flushing must occur only at transaction commit
+ */
+ COMMIT,
+ /**
+ * (Default) Flushing to occur at query execution
+ */
+ AUTO
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,32 @@
+//$Id: GeneratedValue.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Provides for the specification of generation strategies for the values of primary keys.
+ * The GeneratedValue annotation may be applied to a primary key property or field of an entity
+ * or mapped superclass in conjunction with the Id annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface GeneratedValue {
+ /**
+ * The primary key generation strategy that the persistence provider must use
+ * to generate the annotated entity primary key.
+ */
+ GenerationType strategy() default GenerationType.AUTO;
+ /**
+ * The name of the primary key generator to use as specified in the SequenceGenerator or
+ * TableGenerator annotation.
+ *
+ * Defaults to the id generator supplied by persistence provider.
+ */
+ String generator() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,34 @@
+//$Id: GenerationType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines the types of primary key generation.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum GenerationType {
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using an underlying
+ * database table to ensure uniqueness.
+ */
+ TABLE,
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using database
+ * sequence column.
+ */
+ SEQUENCE,
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using
+ * database identity column.
+ */
+ IDENTITY,
+ /**
+ * Indicates that the persistence provider should pick an appropriate strategy for the
+ * particular database. The AUTO generation strategy may expect a database resource
+ * to exist, or it may attempt to create one. A vendor may provide documentation on how
+ * to create such resources in the event that it does not support schema generation or cannot
+ * create the schema resource at runtime.
+ */
+ AUTO
+};
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,18 @@
+//$Id: Id.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+
+/**
+ * Specifies the primary key property or field of an entity.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Id {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,26 @@
+//$Id: IdClass.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Specifies a composite primary key class that is mapped to multiple fields or properties
+ * of the entity.
+ *
+ * The names of the fields or properties in the primary key class and the primary key fields
+ * or properties of the entity must correspond and their types must be the same.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface IdClass {
+ /**
+ * Primary key class
+ */
+ Class value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+//$Id: Inheritance.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import static javax.persistence.InheritanceType.SINGLE_TABLE;
+
+/**
+ * Defines the inheritance strategy to be used for an entity class hierarchy. It is specified
+ * on the entity class that is the root of the entity class hierarchy.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface Inheritance {
+ /**
+ * The strategy to be used
+ */
+ InheritanceType strategy() default SINGLE_TABLE;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+//$Id: InheritanceType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines inheritance strategy options.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum InheritanceType
+{
+ /**
+ * A single table per class hierarchy
+ */
+ SINGLE_TABLE,
+ /**
+ * A table per concrete entity class
+ */
+ TABLE_PER_CLASS,
+ /**
+ * A strategy in which fields that are specific to a subclass are mapped to a separate
+ * table than the fields that are common to the parent class, and a join is performed
+ * to instantiate the subclass.
+ */
+ JOINED };
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,67 @@
+//$Id: JoinColumn.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Is used to specify a mapped column for joining an entity association.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface JoinColumn {
+ /**
+ * The name of the foreign key column.
+ * The table in which it is found depends upon the context. If the join is for a OneToOne
+ * or Many- ToOne mapping, the foreign key column is in the table of the source entity.
+ * If the join is for a ManyToMany, the foreign key is in a join table. Default (only applies
+ * if a single join column is used): The concatenation of the following: the name of the referencing
+ * relationship property or field of the referencing entity; "_"; the name of the referenced primary
+ * key column. If there is no such referencing relationship property or field in the entity, the join
+ * column name is formed as the concatenation of the following: the name of the entity; "_"; the name
+ * of the referenced primary key column.
+ */
+ String name() default "";
+ /**
+ * The name of the column referenced by this foreign key column. When used with relationship mappings,
+ * the referenced column is in the table of the target entity. When used inside a JoinTable annotation,
+ * the referenced key column is in the entity table of the owning entity, or inverse entity if the join
+ * is part of the inverse join definition. Default (only applies if single join column is being used):
+ * The same name as the primary key column of the referenced table.
+ */
+ String referencedColumnName() default "";
+ /**
+ * Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the
+ * table level and is useful for when the unique key constraint is only a single field. It is not
+ * necessary to explicitly specify this for a join column that corresponds to a primary key that is part
+ * of a foreign key.
+ */
+ boolean unique() default false;
+ /**
+ * Whether the foreign key column is nullable
+ */
+ boolean nullable() default true;
+ /**
+ * Whether the column is included in SQL INSERT statements generated by the persistence provider
+ */
+ boolean insertable() default true;
+ /**
+ * Whether the column is included in SQL UPDATE statements generated by the persistence provider
+ */
+ boolean updatable() default true;
+ /**
+ * The SQL fragment that is used when generating the DDL for the column.
+ * Defaults to the generated SQL for the column.
+ */
+ String columnDefinition() default "";
+ /**
+ * The name of the table that contains the column. If a table is not specified, the column is
+ * assumed to be in the primary table of the applicable entity
+ */
+ String table() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+//$Id: JoinColumns.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Defines mapping for the composite foreign keys.
+ * This annotation groups JoinColumn annotations for the same relationship.
+ *
+ * When the JoinColumns annotation is used, both the name and the referencedColumnName
+ * elements must be specified in each such JoinColumn annotation.
+
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface JoinColumns {
+ JoinColumn[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,63 @@
+//$Id: JoinTable.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation is used in the mapping of associations. It is specified on the owning
+ * side of a many-to-many association, or in a unidirectional one-to-many association.
+ *
+ * If the JoinTable annotation is missing, the default values of the annotation elements apply.
+ * The name of the join table is assumed to be the table names of the associated primary tables
+ * concatenated together (owning side first) using an underscore.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface JoinTable {
+ /**
+ * The name of the join table.
+ *
+ * Defaults to the concatenated names of the two associated primary entity tables,
+ * separated by an underscore
+ */
+ String name() default "";
+ /**
+ * The catalog of the table.
+ *
+ * Defaults to the default catalog.
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table.
+ *
+ * Defaults to the default schema for user.
+ */
+ String schema() default "";
+ /**
+ * The foreign key columns of the join table which reference the primary table of the
+ * entity owning the association (i.e. the owning side of the association).
+ *
+ * Uses the same defaults as for JoinColumn.
+ */
+ JoinColumn[] joinColumns() default {};
+ /**
+ * The foreign key columns of the join table which reference the primary table of the entity
+ * that does not own the association (i.e. the inverse side of the association).
+ *
+ * Uses the same defaults as for JoinColumn
+ */
+ JoinColumn[] inverseJoinColumns() default {};
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table
+ * generation is in effect.
+ *
+ * Defaults to no additional constraints
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+//$Id: Lob.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.METHOD;
+
+import static java.lang.annotation.ElementType.FIELD;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+
+/**
+ * Specifies that a persistent property or field should be persisted as a large object to a
+ * database-supported large object type. The Lob annotation may be used in conjunction with
+ * the Basic annotation. A Lob may be either a binary or character type.
+ *
+ * The Lob type is inferred from the type of the persistent field or property, and except
+ * for string and character-based types defaults to Blob.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Lob {}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,40 @@
+//$Id: LockModeType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Lock modes that can be specified by means of the EntityManager.lock() method.
+ *
+ * The semantics of requesting locks of type LockModeType.READ and LockModeType.WRITE are t
+ * he following.
+ *
+ * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
+ * manager must ensure that neither of the following phenomena can occur:
+ *
+ * * P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads
+ * that row and obtains the modified value, before T1 has committed or rolled back.
+ * Transaction T2 eventually commits successfully; it does not matter whether T1 commits or rolls
+ * back and whether it does so before or after T2 commits.
+ *
+ * * P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies
+ * or deletes that row, before T1 has committed. Both transactions eventually commit successfully.
+ *
+ * Lock modes must always prevent the phenomena P1 and P2.
+ * In addition, calling lock(entity, LockModeType.WRITE) on a versioned object,
+ * will also force an update (increment) to the entity's version column.
+ *
+ * The persistence implementation is not required to support calling EntityManager.lock()
+ * on a non-versioned object. When it cannot support a such lock call, it must
+ * throw the PersistenceException.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum LockModeType {
+ /**
+ * Read lock
+ */
+ READ,
+ /**
+ * Write lock
+ */
+ WRITE
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,51 @@
+//$Id: ManyToMany.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * Defines a many-valued association with many-to-many multiplicity. If the Collection is
+ * defined using generics to specify the element type, the associated target entity class
+ * does not need to be specified; otherwise it must be specified.
+ *
+ * Every many-to-many association has two sides, the owning side and the non-owning, or inverse,
+ * side. The join table is specified on the owning side. If the association is bidirectional,
+ * either side may be designated as the owning side.
+ *
+ * The same annotation elements for the OneToMany annotation apply to the ManyToMany annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface ManyToMany {
+ /**
+ * The entity class that is the target of the association. Optional only if the
+ * collection property is defined using Java generics. Must be specified otherwise.
+ *
+ * Defaults to the parameterized type of the collection when defined using generics.
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * Defaults to no operations being cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistenceprovider runtime that
+ * the associatedentities must be eagerly fetched. The LAZY strategy is a hint
+ * to the persistence provider runtime.
+ */
+ FetchType fetch() default LAZY;
+ /**
+ * The field that owns the relationship. Required unless the relationship is unidirectional.
+ */
+ String mappedBy() default "";
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,44 @@
+//$Id: ManyToOne.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * This annotation defines a single-valued association to another entity class that has
+ * many-to-one multiplicity. It is not normally necessary to specify the target entity
+ * explicitly since it can usually be inferred from the type of the object being referenced.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface ManyToOne {
+ /**
+ * The entity class that is the target of the association.
+ *
+ * Defaults to the type of the field or property that stores the association
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * By default no operations are cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistence provider runtime that
+ * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+ * the persistence provider runtime.
+ */
+ FetchType fetch() default EAGER;
+ /**
+ * Whether the association is optional. If set to false then a non-null relationship must always exist.
+ */
+ boolean optional() default true;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+
+/**
+ * Is used to specify the map key for associations of type Map.
+ * If a persistent field or property other than the primary key is used as a map key then it
+ * is expected to have a uniqueness constraint associated with it.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface MapKey {
+ /**
+ * The name of the persistent field or property of the associated entity that is used as the map key.
+ * If the name element is not specified, the primary key of the associated entity is used as the map key.
+ * If the primary key is a composite primary key and is mapped as IdClass, an instance of the primary key
+ * class is used as the key.
+ */
+ String name() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+//$Id: MappedSuperclass.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Designates a class whose mapping information is applied to the entities that inherit
+ * from it. A mapped superclass has no separate table defined for it.
+ *
+ * A class designated with the MappedSuperclass annotation can be mapped in the same way as
+ * an entity except that the mappings will apply only to its subclasses since no table exists
+ * for the mapped superclass itself. When applied to the subclasses the inherited mappings will
+ * apply in the context of the subclass tables. Mapping information may be overridden in such
+ * subclasses by using the AttributeOverride and AssociationOverride annotations or corresponding *
+ * XML elements.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface MappedSuperclass {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,21 @@
+//$Id: NamedNativeQueries.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Is used to specify an array of native SQL named queries. Query names are scoped to the persistence unit
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface NamedNativeQueries {
+ /**
+ * Array of native SQL named queries
+ */
+ NamedNativeQuery [] value ();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,39 @@
+//$Id: NamedNativeQuery.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.*;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Is used to specify a native SQL named query. Query names are scoped to the persistence unit.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE})
+@Retention(RUNTIME)
+public @interface NamedNativeQuery {
+ /**
+ * Is used to refer to the query when using the EntityManager methods that create query objects
+ */
+ String name();
+ /**
+ * The SQL query string
+ */
+ String query();
+
+ /**
+ * Vendor-specific query hints
+ */
+ QueryHint[] hints() default {};
+ /**
+ * The class of the result
+ */
+ Class resultClass() default void.class;
+ /**
+ * The name of a SqlResultSetMapping, as defined in metadata
+ */
+ String resultSetMapping() default ""; // name of SQLResultSetMapping
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,21 @@
+//$Id: NamedQueries.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Specifies an array of named Java Persistence query language queries. Query names are scoped to the persistence unit.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface NamedQueries {
+ /**
+ * An array of named Java Persistence query language queries.
+ */
+ NamedQuery [] value ();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,31 @@
+//$Id: NamedQuery.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+/**
+ * Is used to specify a named query in the Java Persistence query language, which is a static
+ * query expressed in metadata. Query names are scoped to the persistence unit.
+ *
+ * @author Emmanuel Bernard
+ */
+//TODO remove the mackage target
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface NamedQuery {
+ /**
+ * Refers to the query when using the EntityManager methods that create query objects.
+ */
+ String name();
+ /**
+ * The query string in the Java Persistence query language
+ */
+ String query();
+ /**
+ * Vendor-specific query hints
+ */
+ QueryHint[] hints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,27 @@
+//$Id: NoResultException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when getSingleResult() is executed on a query and there is no result to return.
+ * This exception will not cause the current transaction, if one is active, to be marked for roll back.
+ *
+ * @author Emmanuel Bernard
+ */
+public class NoResultException extends PersistenceException {
+
+ /**
+ * Constructs a new NoResultException exception with null as its detail message
+ */
+ public NoResultException() {
+ super();
+ }
+
+ /**
+ * Constructs a new NoResultException exception with the specified detail message.
+ *
+ * @param message
+ */
+ public NoResultException(String message) {
+ super( message );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,29 @@
+//$Id: NonUniqueResultException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when getSingleResult() is executed on a query and there is more than
+ * one result from the query. This exception will not cause the current transaction, if one is active, to be
+ * marked for roll back.
+ *
+ * @author Gavin King
+ */
+public class NonUniqueResultException extends PersistenceException {
+
+ /**
+ * Constructs a new NonUniqueResultException exception with null as its detail message
+ */
+ public NonUniqueResultException() {
+ super();
+ }
+
+ /**
+ * Constructs a new NonUniqueResultException exception with the specified detail message
+ *
+ * @param message
+ */
+ public NonUniqueResultException(String message) {
+ super( message );
+ }
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,47 @@
+//$Id: OneToMany.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * Defines a many-valued association with one-to-many multiplicity.
+ *
+ * If the collection is defined using generics to specify the element type,
+ * the associated target entity type need not be specified; otherwise the target
+ * entity class must be specified.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface OneToMany {
+ /**
+ * The entity class that is the target of the association. Optional only if the collection
+ * property is defined using Java generics. Must be specified otherwise.
+ *
+ * Defaults to the parameterized type of the collection when defined using generics.
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * Defaults to no operations being cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistenceprovider runtime that the
+ * associatedentities must be eagerly fetched. The LAZY strategy is a hint to the
+ * persistence provider runtime.
+ */
+ FetchType fetch() default LAZY;
+ /**
+ * The field that owns the relationship. Required unless the relationship is unidirectional.
+ */
+ String mappedBy() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,51 @@
+//$Id: OneToOne.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * This annotation defines a single-valued association to another entity that has
+ * one-to-one multiplicity. It is not normally necessary to specify the associated
+ * target entity explicitly since it can usually be inferred from the type of the object
+ * being referenced.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface OneToOne {
+ /**
+ * The entity class that is the target of the association.
+ *
+ * Defaults to the type of the field or property that stores the association.
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * By default no operations are cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistence provider runtime that
+ * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+ * the persistence provider runtime.
+ */
+ FetchType fetch() default EAGER;
+ /**
+ * Whether the association is optional. If set to false then a non-null relationship must
+ * always exist.
+ */
+ boolean optional() default true;
+ /**
+ * The field that owns the relationship. This element is only specified on the
+ * inverse (non-owning) side of the association.
+ */
+ String mappedBy() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,42 @@
+//$Id: $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when an optimistic locking conflict occurs.
+ * This exception may be thrown as part of an API call, a flush or at commit time.
+ * The current transaction, if one is active, will be marked for rollback.
+ *
+ * @author Emmanuel Bernard
+ */
+public class OptimisticLockException extends PersistenceException {
+ private Object entity;
+
+ public OptimisticLockException() {
+ super();
+ }
+
+ public OptimisticLockException(Object entity) {
+ this.entity = entity;
+ }
+
+ public OptimisticLockException(Throwable cause) {
+ super( cause );
+ }
+
+ public OptimisticLockException(String message) {
+ super( message );
+ }
+
+ public OptimisticLockException(String message, Throwable cause) {
+ super( message, cause );
+ }
+
+ public OptimisticLockException(String message, Throwable cause, Object entity) {
+ super( message, cause );
+ this.entity = entity;
+ }
+
+ public Object getEntity() {
+ return entity;
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,39 @@
+//$Id: OrderBy.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies the ordering of the elements of a collection valued association at the
+ * point when the association is retrieved.
+ *
+ * The syntax of the value ordering element is an orderby_list, as follows:
+ * <code>orderby_list::= orderby_item [,orderby_item]*
+ * orderby_item::= property_or_field_name [ASC | DESC]</code>
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ * If the ordering element is not specified, ordering by the primary key of the associated
+ * entity is assumed.
+ *
+ * The property or field name must correspond to that of a persistent property or field of the
+ * associated class. The properties or fields used in the ordering must correspond to columns
+ * for which comparison operators are supported.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface OrderBy {
+ /**
+ * An orderby_list, specified as follows:
+ * orderby_list::= orderby_item [,orderby_item]* orderby_item::= property_or_field_name [ASC | DESC]
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ */
+ String value() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,110 @@
+// $Id: Persistence.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.persistence.spi.PersistenceProvider;
+
+/**
+ * Bootstrap class that provides access to an EntityManagerFactory.
+ */
+public class Persistence {
+
+ public static String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
+
+ protected static final Set<PersistenceProvider> providers = new HashSet<PersistenceProvider>();
+
+ /**
+ * Create and return an EntityManagerFactory for the named persistence unit.
+ *
+ * @param persistenceUnitName The name of the persistence unit
+ * @return The factory that creates EntityManagers configured according to the specified persistence unit
+ */
+ public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName) {
+ return createEntityManagerFactory( persistenceUnitName, null );
+ }
+
+ /**
+ * Create and return an EntityManagerFactory for the named persistence unit using the given properties.
+ *
+ * @param persistenceUnitName The name of the persistence unit
+ * @param properties Additional properties to use when creating the factory. The values of these properties override
+ * any values that may have been configured elsewhere
+ * @return The factory that creates EntityManagers configured according to the specified persistence unit
+ */
+ public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
+ EntityManagerFactory emf = null;
+
+ if ( providers.size() == 0 ) {
+ findAllProviders();
+ }
+ for ( PersistenceProvider provider : providers ) {
+ emf = provider.createEntityManagerFactory( persistenceUnitName, properties );
+ if ( emf != null ) break;
+ }
+ if ( emf == null ) {
+ throw new PersistenceException( "No Persistence provider for EntityManager named " + persistenceUnitName );
+ }
+ return emf;
+ }
+
+ // Helper methods
+
+ private static void findAllProviders() {
+ try {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Enumeration<URL> resources = loader.getResources( "META-INF/services/" + PersistenceProvider.class.getName() );
+ Set<String> names = new HashSet<String>();
+ while ( resources.hasMoreElements() ) {
+ URL url = resources.nextElement();
+ InputStream is = url.openStream();
+ try {
+ names.addAll( providerNamesFromReader( new BufferedReader( new InputStreamReader( is ) ) ) );
+ }
+ finally {
+ is.close();
+ }
+ }
+ for ( String s : names ) {
+ Class providerClass = loader.loadClass( s );
+ providers.add( (PersistenceProvider) providerClass.newInstance() );
+ }
+ }
+ catch (IOException e) {
+ throw new PersistenceException( e );
+ }
+ catch (InstantiationException e) {
+ throw new PersistenceException( e );
+ }
+ catch (IllegalAccessException e) {
+ throw new PersistenceException( e );
+ }
+ catch (ClassNotFoundException e) {
+ throw new PersistenceException( e );
+ }
+ }
+
+ private static final Pattern nonCommentPattern = Pattern.compile( "^([^#]+)" );
+
+ private static Set<String> providerNamesFromReader(BufferedReader reader) throws IOException {
+ Set<String> names = new HashSet<String>();
+ String line;
+ while ( ( line = reader.readLine() ) != null ) {
+ line = line.trim();
+ Matcher m = nonCommentPattern.matcher( line );
+ if ( m.find() ) {
+ names.add( m.group().trim() );
+ }
+ }
+ return names;
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,43 @@
+/* $Id: PersistenceContext.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Expresses a dependency on an EntityManager persistence context.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceContext {
+ /**
+ * The name by which the entity manager is to be accessed in the environment referencing context,
+ * and is not needed when dependency injection is used.
+ */
+ String name() default "";
+ /**
+ * The name of the persistence unit. If the unitName element is specified, the persistence unit
+ * for the entity manager that is accessible in JNDI must have the same name.
+ */
+ String unitName() default "";
+ /**
+ * Used to specify properties for the container or persistence provider. Vendor specific
+ * properties may be included in this set of properties. Properties that are not
+ * recognized by a vendor are ignored.
+ */
+ PersistenceProperty[] properties() default {};
+ /**
+ * Specifies whether this is a transaction-scoped persistence context or
+ * an extended persistence context.
+ */
+ PersistenceContextType type() default PersistenceContextType.TRANSACTION;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,18 @@
+//$Id: PersistenceContextType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Specifies whether a transaction-scoped or extended persistence context is to be used in
+ * PersistenceContext. If the type element is not specified, a transaction-scoped persistence
+ * context is used.
+ */
+public enum PersistenceContextType {
+ /**
+ * Transaction-scoped persistence context
+ */
+ TRANSACTION,
+ /**
+ * Extended persistence context
+ */
+ EXTENDED
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,27 @@
+/* $Id: PersistenceContexts.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares one or more PersistenceContext annotations. It is used to express a dependency on
+ * container-managed entity manager persistence contexts.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceContexts {
+ /**
+ * One or more persistence context
+ */
+ PersistenceContext[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,50 @@
+/* $Id: PersistenceException.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss, Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when a problem occurs. All instances of PersistenceException
+ * except for instances of NoResultException and NonUniqueResultException will cause the current
+ * transaction, if one is active, to be marked for rollback.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+public class PersistenceException extends RuntimeException {
+ /**
+ * Constructs a new PersistenceException exception with null as its detail message.
+ */
+ public PersistenceException() {
+ }
+
+ /**
+ * Constructs a new PersistenceException exception with the specified detail message.
+ *
+ * @param message the detail message
+ */
+ public PersistenceException(String message) {
+ super( message );
+ }
+
+ /**
+ * Constructs a new PersistenceException exception with the specified detail message and cause
+ *
+ * @param message the detail message
+ * @param cause the cause
+ */
+ public PersistenceException(String message, Throwable cause) {
+ super( message, cause );
+ }
+
+ /**
+ * Constructs a new PersistenceException exception with the specified cause
+ *
+ * @param cause the cause
+ */
+ public PersistenceException(Throwable cause) {
+ super( cause );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,27 @@
+//$Id: $
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Describes a single container or persistence provider property.
+ * Vendor specific properties may be included in the set of properties, and are passed to the persistence
+ * provider by the container when the entity manager is created.
+ * Properties that are not recognized by a vendor will be ignored.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({})
+@Retention(RUNTIME)
+public @interface PersistenceProperty {
+ /**
+ * The name of the property
+ */
+ String name();
+ /**
+ * The value of the property
+ */
+ String value();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,33 @@
+/* $Id: PersistenceUnit.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Expresses a dependency on an EntityManagerFactory.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceUnit {
+ /**
+ * The name by which the entity manager factory is to be accessed in the environment
+ * referencing context, and is not needed when dependency injection is used.
+ */
+ String name() default "";
+ /**
+ * The name of the persistence unit as defined in the persistence.xml file. If specified, the
+ * persistence unit for the entity manager factory that is accessible in JNDI must have the
+ * same name.
+ */
+ String unitName() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,26 @@
+/* $Id: PersistenceUnits.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares one or more PersistenceUnit annotations
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceUnits {
+ /**
+ * One or more PersistenceUnit annotations
+ */
+ PersistenceUnit[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,24 @@
+/* $Id: PostLoad.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to
+ * methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostLoad {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+/* $Id: PostPersist.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be
+ * applied to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostPersist {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+/* $Id: PostRemove.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostRemove {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+/* $Id: PostUpdate.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to
+ * methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostUpdate {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+/* $Id: PrePersist.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PrePersist {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+/* $Id: PreRemove.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PreRemove {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+/* $Id: PreUpdate.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be
+ * applied to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PreUpdate {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,53 @@
+//$Id: PrimaryKeyJoinColumn.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies a primary key column that is used as a foreign key to join to another
+ * table.
+ *
+ * It is used to join the primary table of an entity subclass in the JOINED mapping strategy to
+ * the primary table of its superclass; it is used within a SecondaryTable annotation to join a
+ * secondary table to a primary table; and it may be used in a OneToOne mapping in which the
+ * primary key of the referencing entity is used as a foreign key to the referenced entity.
+ *
+ * If no PrimaryKeyJoinColumn annotation is specified for a subclass in the JOINED mapping
+ * strategy, the foreign key columns are assumed to have the same names as the primary key
+ * columns of the primary table of the superclass
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface PrimaryKeyJoinColumn {
+ /**
+ * The name of the primary key column of the current table.
+ *
+ * Defaults to the same name as the primary key column of the primary table of the
+ * superclass (JOINED mapping strategy); the same name as the primary key column of
+ * the primary table (SecondaryTable mapping); or the same name as the primary key
+ * column for the table for the referencing entity (OneToOne mapping)
+ */
+ String name() default "";
+ /**
+ * The name of the primary key column of the table being joined to.
+ *
+ * Defaults to the same name as the primary key column of the primary table of the
+ * superclass (JOINED mapping strategy); the same name as the primary key column of the
+ * primary table (SecondaryTable mapping); or the same name as the primary key column for
+ * the table for the referencing entity (OneToOne mapping)
+ */
+ String referencedColumnName() default "";
+ /**
+ * The SQL fragment that is used when generating the DDL for the column. This should not be
+ * specified for a OneToOne primary key association.
+ *
+ * Defaults to the generated SQL to create a column of the inferred type.
+ */
+ String columnDefinition() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,22 @@
+//$Id: PrimaryKeyJoinColumns.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation groups PrimaryKeyJoinColumn annotations. It is used to map composite foreign keys.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface PrimaryKeyJoinColumns {
+ /**
+ * One or more PrimaryKeyJoinColumn annotations
+ */
+ PrimaryKeyJoinColumn[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,148 @@
+// $Id: Query.java 11225 2007-02-20 20:55:29Z epbernard $
+package javax.persistence;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * Interface used to control query execution.
+ */
+public interface Query
+{
+ /**
+ * Execute the query and return the query results as a List.
+ *
+ * @return a list of the results
+ * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
+ */
+ public List getResultList();
+
+ /**
+ * Execute a SELECT query that returns a single result.
+ *
+ * @return the result
+ * @throws NoResultException if there is no result
+ * @throws NonUniqueResultException if more than one result
+ * @throws IllegalStateException if called for a Java
+ * Persistence query language UPDATE or DELETE statement
+ */
+ public Object getSingleResult();
+
+ /**
+ * Execute an update or delete statement.
+ *
+ * @return the number of entities updated or deleted
+ * @throws IllegalStateException if called for a Java Persistence query language SELECT statement
+ * @throws TransactionRequiredException if there is no transaction
+ */
+ public int executeUpdate();
+
+ /**
+ * Set the maximum number of results to retrieve.
+ *
+ * @param maxResult
+ * @return the same query instance
+ * @throws IllegalArgumentException if argument is negative
+ */
+ public Query setMaxResults(int maxResult);
+
+ /**
+ * Set the position of the first result to retrieve.
+ *
+ * @param startPosition position of the first result, numbered from 0
+ * @return the same query instance
+ * @throws IllegalArgumentException if argument is negative
+ */
+ public Query setFirstResult(int startPosition);
+
+ /**
+ * Set an implementation-specific hint. If the hint name is not recognized, it is silently
+ * ignored.
+ *
+ * @param hintName
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if the second argument is not valid for the implementation
+ */
+ public Query setHint(String hintName, Object value);
+
+ /**
+ * Bind an argument to a named parameter.
+ *
+ * @param name the parameter name
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string or argument is of incorrect type
+ */
+ public Query setParameter(String name, Object value);
+
+ /**
+ * Bind an instance of java.util.Date to a named parameter.
+ *
+ * @param name
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string
+ */
+ public Query setParameter(String name, Date value, TemporalType temporalType);
+
+ /**
+ * Bind an instance of java.util.Calendar to a named parameter.
+ *
+ * @param name
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string
+ */
+ public Query setParameter(String name, Calendar value, TemporalType temporalType);
+
+ /**
+ * Bind an argument to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if position does not correspond to positional parameter of
+ * query or argument is of incorrect type
+ */
+ public Query setParameter(int position, Object value);
+
+ /**
+ * Bind an instance of java.util.Date to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if position does not correspond to positional parameter of
+ * query
+ */
+ public Query setParameter(int position, Date value, TemporalType temporalType);
+
+ /**
+ * Bind an instance of java.util.Calendar to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @param temporalType
+ * @return the same query instance } correspond to positional parameter of query
+ */
+ public Query setParameter(int position, Calendar value, TemporalType temporalType);
+
+ /**
+ * Set the flush mode type to be used for the query execution.
+ * The flush mode type applies to the query regardless of the
+ * flush mode type in use for the entity manager.
+ *
+ * @param flushMode
+ */
+ public Query setFlushMode(FlushModeType flushMode);
+
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+//$Id: QueryHint.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * An implementation-specific Query hint
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({})
+@Retention(RUNTIME)
+public @interface QueryHint {
+ /**
+ * Name of the hint
+ */
+ String name();
+
+ /**
+ * Value of the hint
+ */
+ String value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,44 @@
+//$Id: $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when the EntityTransaction.commit() fails
+ *
+ * @author Emmanuel Bernard
+ */
+public class RollbackException extends PersistenceException {
+ /**
+ * Constructs a new RollbackException exception with null as its detail message
+ */
+ public RollbackException() {
+ super();
+ }
+
+ /**
+ * Constructs a new RollbackException exception with the specified cause
+ *
+ * @param cause The detail cause
+ */
+ public RollbackException(Throwable cause) {
+ super( cause );
+ }
+
+ /**
+ * Constructs a new RollbackException exception with the specified detail message
+ *
+ * @param message The detail message
+ */
+ public RollbackException(String message) {
+ super( message );
+ }
+
+ /**
+ * Constructs a new RollbackException exception with the specified detail message and cause
+ *
+ * @param message The detail message
+ * @param cause The detail cause
+ */
+ public RollbackException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,53 @@
+//$Id: SecondaryTable.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation is used to specify a secondary table for the annotated entity class. Specifying
+ * one or more secondary tables indicates that the data for the entity class is stored across multiple
+ * tables.
+ *
+ * If no SecondaryTable annotation is specified, it is assumed that all persistent fields or properties
+ * of the entity are mapped to the primary table. If no primary key join columns are specified, the
+ * join columns are assumed to reference the primary key columns of the primary table, and have the
+ * same names and types as the referenced primary key columns of the primary table.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface SecondaryTable {
+ /**
+ * The name of the table
+ */
+ String name();
+ /**
+ * The catalog of the table
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table
+ */
+ String schema() default "";
+ /**
+ * The columns that are used to join with the primary table.
+ *
+ * Defaults to the column(s) of the same name(s) as the primary key column(s)
+ * in the primary table
+ */
+ PrimaryKeyJoinColumn[] pkJoinColumns() default {};
+ /**
+ * Unique constraints that are to be placed on the table. These are typically only used if
+ * table generation is in effect. These constraints apply in addition to any constraints
+ * specified by the Column and JoinColumn annotations and constraints entailed by primary
+ * key mappings.
+ *
+ * Defaults to no additional constraints.
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,21 @@
+//$Id: SecondaryTables.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+/**
+ * This annotation is used to specify multiple secondary tables for an entity.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface SecondaryTables {
+ /**
+ * The secondary tables for an entity.
+ */
+ SecondaryTable[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,38 @@
+//$Id: SequenceGenerator.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation defines a primary key generator that may be referenced by name when a generator
+ * element is specified for the GeneratedValue annotation. A sequence generator may be specified on
+ * the entity class or on the primary key field or property. The scope of the generator name is global
+ * to the persistence unit (across all generator types).
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface SequenceGenerator {
+ /**
+ * A unique generator name that can be referenced by one or more classes to be the generator for primary key values
+ */
+ String name();
+ /**
+ * The name of the database sequence object from which to obtain primary key values
+ * Defaults to a provider-chosen value
+ */
+ String sequenceName() default "";
+ /**
+ * The value from which the sequence object is to start generating
+ */
+ int initialValue() default 1;
+ /**
+ * The amount to increment by when allocating sequence numbers from the sequence
+ */
+ int allocationSize() default 50;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,29 @@
+//$Id: SqlResultSetMapping.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation is used to specify the mapping of the result of a native SQL query
+ *
+ * @author Emmanuel Bernard
+ */
+(a)Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
+public @interface SqlResultSetMapping {
+ /**
+ * The name given to the result set mapping, and used to refer to it in the methods of the Query API
+ */
+ String name();
+ /**
+ * Specifies the result set mapping to entities
+ */
+ EntityResult[] entities() default {};
+ /**
+ * Specifies the result set mapping to scalar values
+ */
+ ColumnResult[] columns() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,19 @@
+//$Id: SqlResultSetMapping.java 9044 2006-01-12 20:58:41 -0500 (jeu., 12 janv. 2006) epbernard $
+//EJB3 Specification Copyright 2004 - 2006 Sun Microsystems, Inc.
+
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation is used to define one or more SqlResultSetMapping
+ *
+ * @author Emmanuel Bernard
+ */
+(a)Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
+public @interface SqlResultSetMappings {
+ SqlResultSetMapping[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,48 @@
+//$Id: Table.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies the primary table for the annotated entity. Additional
+ * tables may be specified using SecondaryTable or SecondaryTables annotation.
+ *
+ * If no Table annotation is specified for an entity class, the default values apply.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface Table {
+ /**
+ * The name of the table.
+ *
+ * Defaults to the entity name.
+ */
+ String name() default "";
+ /**
+ * The catalog of the table.
+ *
+ * Defaults to the default catalog.
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table.
+ *
+ * Defaults to the default schema for user.
+ */
+ String schema() default "";
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table
+ * generation is in effect. These constraints apply in addition to any constraints
+ * specified by the Column and JoinColumn annotations and constraints entailed by
+ * primary key mappings.
+ *
+ * Defaults to no additional constraints.
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,67 @@
+//$Id: TableGenerator.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.*;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation defines a primary key generator that may be referenced by name when a generator
+ * element is specified for the GeneratedValue annotation. A table generator may be specified on the
+ * entity class or on the primary key field or property. The scope of the generator name is global to
+ * the persistence unit (across all generator types).
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface TableGenerator {
+ /**
+ * A unique generator name that can be referenced by one or more classes to be the generator for id values
+ */
+ String name();
+ /**
+ * Name of table that stores the generated id values. Defaults to a name chosen by persistence provider.
+ */
+ String table() default "";
+ /**
+ * The catalog of the table
+ * Defaults to the default catalog
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table
+ * Defaults to the default schema for user
+ */
+ String schema() default "";
+ /**
+ * Name of the primary key column in the table
+ * Defaults to a provider-chosen name
+ */
+ String pkColumnName() default "";
+ /**
+ * Name of the column that stores the last value generated
+ * Defaults to a provider-chosen name
+ */
+ String valueColumnName() default "";
+ /**
+ * The primary key value in the generator table that distinguishes this set of generated values from others that may be stored in the table
+ * Defaults to a provider-chosen value to store in the primary key column of the generator table
+ */
+ String pkColumnValue() default "";
+ /**
+ * The initial value to be used when allocating id numbers from the generator
+ */
+ int initialValue() default 0;
+ /**
+ * The amount to increment by when allocating id numbers from the generator
+ */
+ int allocationSize() default 50;
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table generation is in effect. These constraints apply in addition to primary key constraints
+ * Defaults to no additional constraints
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,26 @@
+//$Id: Temporal.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation must be specified for persistent fields or properties of type Date and Calendar.
+ * It may only be specified for fields or properties of these types.
+ *
+ * The Temporal annotation may be used in conjunction with the Basic annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Temporal {
+ /**
+ * The type used in mapping java.util.Date or java.util.Calendar
+ */
+ TemporalType value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,21 @@
+//$Id: TemporalType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Type used to indicate a specific mapping of Date or Calendar.
+ */
+public enum TemporalType {
+ /**
+ * Map as java.sql.Date
+ */
+ DATE,
+ /**
+ * Map as java.sql.Time
+ */
+ TIME,
+ /**
+ * Map as java.sql.Timestamp
+ */
+ TIMESTAMP
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,26 @@
+//$Id: TransactionRequiredException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when a transaction is required but is not active.
+ * @author Gavin King
+ */
+public class TransactionRequiredException extends PersistenceException {
+
+ /**
+ * Constructs a new TransactionRequiredException exception with null as its detail message
+ */
+ public TransactionRequiredException() {
+ super();
+ }
+
+ /**
+ * Constructs a new TransactionRequiredException exception with the specified detail message
+ *
+ * @param message
+ */
+ public TransactionRequiredException(String message) {
+ super( message );
+ }
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,18 @@
+//$Id: Transient.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies that the property or field is not persistent. It is used to annotate
+ * a property or field of an entity class, mapped superclass, or embeddable class.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Transient {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,21 @@
+//$Id: UniqueConstraint.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used to specify that a unique constraint is to be included in the generated DDL
+ * for a primary or secondary table
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RUNTIME)
+public @interface UniqueConstraint {
+ /**
+ * An array of the column names that make up the constraint
+ */
+ String[] columnNames();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,28 @@
+//$Id: Version.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies the version field or property of an entity class that serves as its
+ * optimistic lock value. The version is used to ensure integrity when performing the merge
+ * operation and for optimistic concurrency control.
+ *
+ * Only a single Version property or field should be used per class; applications that use more
+ * than one Version property or field will not be portable.
+ *
+ * The Version property should be mapped to the primary table for the entity class; applications
+ * that map the Version property to a table other than the primary table will not be portable.
+ *
+ * The following types are supported for version properties: int, Integer, short, Short, long,
+ * Long, Timestamp.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Version {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,9 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+
+/**
+ * The javax.persistence package contains the classes and interfaces that define the contracts
+ * between a persistence provider and the managed classes and the clients of the Java Persistence API.
+ */
+package javax.persistence;
+
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,39 @@
+//$Id: ClassTransformer.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence.spi;
+
+import java.security.ProtectionDomain;
+import java.lang.instrument.IllegalClassFormatException;
+
+/**
+ * A persistence provider provides an instance of this interface
+ * to the PersistenceUnitInfo.addTransformer method.
+ * The supplied transformer instance will get called to transform
+ * entity class files when they are loaded and redefined. The transformation
+ * occurs before the class is defined by the JVM
+ *
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @version $Revision: 11171 $
+ */
+public interface ClassTransformer
+{
+ /**
+ * Invoked when a class is being loaded or redefined to add hooks for persistence bytecode manipulation
+ *
+ * @param loader the defining class loaderof the class being transformed. It may be null if using bootstrap loader
+ * @param classname The name of the class being transformed
+ * @param classBeingRedefined If an already loaded class is being redefined, then pass this as a parameter
+ * @param protectionDomain ProtectionDomain of the class being (re)-defined
+ * @param classfileBuffer The input byte buffer in class file format
+ * @return A well-formed class file that can be loaded
+ *
+ * @throws IllegalClassFormatException
+ */
+ byte[] transform(ClassLoader loader,
+ String classname,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer)
+ throws IllegalClassFormatException;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,43 @@
+//$Id: PersistenceProvider.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence.spi;
+
+import java.util.Map;
+import javax.persistence.EntityManagerFactory;
+
+/**
+ * Interface implemented by the persistence provider.
+ * This interface is used to create an EntityManagerFactory.
+ * It is invoked by the container in Java EE environments and
+ * by the Persistence class in Java SE environments.
+ */
+public interface PersistenceProvider {
+ /**
+ * Called by Persistence class when an EntityManagerFactory
+ * is to be created.
+ *
+ * @param emName The name of the persistence unit
+ * @param map A Map of properties for use by the
+ * persistence provider. These properties may be used to
+ * override the values of the corresponding elements in
+ * the persistence.xml file or specify values for
+ * properties not specified in the persistence.xml
+ * (and may be null if no properties are specified).
+ * @return EntityManagerFactory for the persistence unit,
+ * or null if the provider is not the right provider
+ */
+ public EntityManagerFactory createEntityManagerFactory(String emName, Map map);
+
+ /**
+ * Called by the container when an EntityManagerFactory
+ * is to be created.
+ *
+ * @param info Metadata for use by the persistence provider
+ * @param map A Map of integration-level properties for use
+ * by the persistence provider (may be null if no properties
+ * are specified).
+ * @return EntityManagerFactory for the persistence unit
+ * specified by the metadata
+ */
+ public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map);
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,142 @@
+//$Id: PersistenceUnitInfo.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.package javax.persistence.spi;
+package javax.persistence.spi;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+import javax.sql.DataSource;
+
+/**
+ * Interface implemented by the container and used by the
+ * persistence provider when creating an EntityManagerFactory.
+ */
+public interface PersistenceUnitInfo {
+ /**
+ * @return The name of the persistence unit.
+ * Corresponds to the <name> element in the persistence.xml file.
+ */
+ public String getPersistenceUnitName();
+
+ /**
+ * @return The fully qualified name of the persistence provider
+ * implementation class.
+ * Corresponds to the <provider> element in the persistence.xml
+ * file.
+ */
+ public String getPersistenceProviderClassName();
+
+ /**
+ * @return The transaction type of the entity managers created
+ * by the EntityManagerFactory.
+ * The transaction type corresponds to the transaction-type
+ * attribute in the persistence.xml file.
+ */
+ public PersistenceUnitTransactionType getTransactionType();
+
+ /**
+ * @return The JTA-enabled data source to be used by the
+ * persistence provider.
+ * The data source corresponds to the <jta-data-source>
+ * element in the persistence.xml file or is provided at
+ * deployment or by the container.
+ */
+ public DataSource getJtaDataSource();
+
+ /**
+ * @return The non-JTA-enabled data source to be used by the
+ * persistence provider for accessing data outside a JTA
+ * transaction.
+ * The data source corresponds to the named <non-jta-data-source>
+ * element in the persistence.xml file or provided at
+ * deployment or by the container.
+ */
+ public DataSource getNonJtaDataSource();
+
+ /**
+ * @return The list of mapping file names that the persistence
+ * provider must load to determine the mappings for the entity
+ * classes. The mapping files must be in the standard XML
+ * mapping format, be uniquely named and be resource-loadable
+ * from the application classpath.
+ * Each mapping file name corresponds to a <mapping-file>
+ * element in the persistence.xml file.
+ */
+ public List<String> getMappingFileNames();
+
+ /**
+ * @return The list of JAR file URLs that the persistence
+ * provider must examine for managed classes of the persistence
+ * unit. Each jar file URL corresponds to a named <jar-file>
+ * element in the persistence.xml file.
+ */
+ public List<URL> getJarFileUrls();
+
+ /**
+ * @return The URL for the jar file or directory that is the
+ * root of the persistence unit. (If the persistence unit is
+ * rooted in the WEB-INF/classes directory, this will be the
+ * URL of that directory.)
+ */
+ public URL getPersistenceUnitRootUrl();
+
+ /**
+ * @return The list of the names of the classes that the
+ * persistence provider must add it to its set of managed
+ * classes. Each name corresponds to a named <class> element
+ * in the persistence.xml file.
+ */
+ public List<String> getManagedClassNames();
+
+ /**
+ * @return Whether classes in the root of the persistence
+ * unit that have not been explicitly listed are to be
+ * included in the set of managed classes.
+ * This value corresponds to the <exclude-unlisted-classes>
+ * element in the persistence.xml file.
+ */
+ public boolean excludeUnlistedClasses();
+
+ /**
+ * @return Properties object. Each property corresponds
+ * to a <property> element in the persistence.xml file
+ */
+ public Properties getProperties();
+
+ /**
+ * @return ClassLoader that the provider may use to load any
+ * classes, resources, or open URLs.
+ */
+ public ClassLoader getClassLoader();
+
+ /**
+ * Add a transformer supplied by the provider that will be
+ * called for every new class definition or class redefinition
+ * that gets loaded by the loader returned by the
+ * PersistenceInfo.getClassLoader method. The transformer
+ * has no effect on the result returned by the
+ * PersistenceInfo.getTempClassLoader method.
+ * Classes are only transformed once within the same classloading
+ * scope, regardless of how many persistence units they may be
+ * a part of.
+ *
+ * @param transformer A provider-supplied transformer that the
+ * Container invokes at class-(re)definition time
+ */
+ public void addTransformer(ClassTransformer transformer);
+
+ /**
+ * Return a new instance of a ClassLoader that the provider
+ * may use to temporarily load any classes, resources, or
+ * open URLs. The scope and classpath of this loader is
+ * exactly the same as that of the loader returned by
+ * PersistenceInfo.getClassLoader. None of the classes loaded
+ * by this class loader will be visible to application
+ * components. The container does not use or maintain references
+ * to this class loader after returning it to the provider.
+ *
+ * @return Temporary ClassLoader with same visibility as current
+ * loader
+ */
+ public ClassLoader getNewTempClassLoader();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,20 @@
+//$Id: PersistenceUnitTransactionType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence.spi;
+
+/**
+ * This enum class defines whether the entity managers created by the EntityManagerFactory will be
+ * JTA or resource-local entity managers.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+public enum PersistenceUnitTransactionType {
+ /**
+ * JTA entity manager
+ */
+ JTA,
+ /**
+ * Resource-local entity manager
+ */
+ RESOURCE_LOCAL
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,10 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+
+/**
+ * The javax.persistence.spi package defines the classes and interfaces that are implemented by the
+ * persistence provider and the Java EE container for use by the container, provider, and/or Persistence
+ * bootstrap class in deployment and bootstrapping.
+ */
+package javax.persistence.spi;
+
Property changes on: workspace/max/jpaap/jpaap
___________________________________________________________________
Name: svn:ignore
+ bin
Added: workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor
===================================================================
--- workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor (rev 0)
+++ workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1 @@
+org.jboss.jpa.metamodel.ap.JPAMetaModelEntityProcessor
\ No newline at end of file
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,23 @@
+package org.jboss.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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,160 @@
+package org.jboss.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;
+
+ 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,152 @@
+package org.jboss.jpa.metamodel.ap;
+
+import static javax.lang.model.SourceVersion.RELEASE_6;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Generated;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.FilerException;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.FileObject;
+
+@SupportedAnnotationTypes("javax.persistence.Entity")
+@SupportedSourceVersion(RELEASE_6)
+public class JPAMetaModelEntityProcessor extends AbstractProcessor {
+
+ public JPAMetaModelEntityProcessor() {
+
+ }
+
+ /**
+ * 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) {
+
+
+ if(aRoundEnvironment.processingOver()) { // No need to run since all our output needs to be considered
+ return false;
+ }
+
+ Set<? extends Element> elements = aRoundEnvironment.getRootElements();
+
+ 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(MetaEntity entity) {
+
+ try {
+ Name metaModelPackage = entity.getPackageName();
+
+
+ StringBuffer body = generateBody(entity);
+
+ FileObject fo = processingEnv.getFiler().createSourceFile(
+ metaModelPackage + "." + entity.getSimpleName() + "_",
+ entity.getOriginalElement());
+ 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(MetaEntity 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.jpa.metamodel.TypesafeMetamodel"));
+
+ pw.println("public abstract class " + entity.getSimpleName() + "_" + " {");
+
+ pw.println();
+
+ List<MetaMember> members = entity.getMembers();
+
+ for (MetaMember metaMember : members) {
+ pw.println( " " + metaMember.getDeclarationString() );
+ }
+ pw.println();
+ pw.println("}");
+ return sw.getBuffer();
+ } finally {
+ if (pw!=null) pw.close();
+ }
+
+
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,33 @@
+package org.jboss.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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,16 @@
+package org.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Element;
+
+public class MetaAttribute extends MetaMember {
+
+ public MetaAttribute(MetaEntity parent, Element element, String type) {
+ super(parent, element, type);
+ }
+
+ @Override
+ protected String getMetaType() {
+ return "javax.jpa.metamodel.Attribute";
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,22 @@
+package org.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Element;
+
+
+public class MetaCollection extends MetaMember {
+
+ private String collectionType;
+
+
+ public MetaCollection(MetaEntity parent, Element element, String collectionType, String elementType) {
+ super(parent, element, elementType);
+ this.collectionType = collectionType;
+ }
+
+ @Override
+ protected String getMetaType() {
+ return collectionType;
+ }
+
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,224 @@
+package org.jboss.jpa.metamodel.ap;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.PrimitiveType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.SimpleTypeVisitor6;
+import javax.tools.Diagnostic.Kind;
+
+public class MetaEntity implements ImportContext {
+
+ 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 Name getSimpleName() {
+ return element.getSimpleName();
+ }
+
+ public Element getOriginalElement() {
+ return element;
+ }
+
+ public Name getQualifiedName() {
+ return element.getQualifiedName();
+ }
+
+ public Name getPackageName() {
+ PackageElement packageOf = pe.getElementUtils().getPackageOf(element);
+ return pe.getElementUtils().getName(packageOf.getQualifiedName() + ".metamodel");
+ }
+
+ public List<MetaMember> getMembers() {
+
+ List<MetaMember> members = new ArrayList<MetaMember>();
+
+ if(useFields()) {
+
+ List<? extends Element> myMembers = ElementFilter.fieldsIn(element.getEnclosedElements());
+
+ System.out.println("Scanning " + myMembers.size() + " field s for " + element.toString());
+
+ for (Element mymember : myMembers) {
+
+ MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
+ if(result!=null) {
+ members.add(result);
+ } else {
+ pe.getMessager().printMessage(Kind.WARNING, "Could not find valid info for JPA property", mymember);
+ }
+ }
+
+ } else {
+
+
+ List<? extends Element> myMembers = ElementFilter.methodsIn(element.getEnclosedElements());
+
+ System.out.println("Scanning " + myMembers.size() + " methods for " + element.toString());
+ for (Element mymember : myMembers) {
+
+ MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
+ if(result!=null) {
+ members.add(result);
+ } else {
+ //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA property", mymember);
+ }
+ }
+
+ }
+
+ if(members.size()==0) {
+ pe.getMessager().printMessage(Kind.WARNING, "No properties found on " + element, element);
+ }
+ return members;
+ }
+
+
+ //TODO: Find more efficient way to identify wether we should use fields or properties
+ private boolean useFields() {
+ List<? extends Element> myMembers = element.getEnclosedElements();
+ for (Element element : myMembers) {
+ List<? extends AnnotationMirror> entityAnnotations =
+ pe.getElementUtils().getAllAnnotationMirrors(element);
+
+ for (Iterator<?> iterator = entityAnnotations.iterator(); iterator
+ .hasNext();) {
+ AnnotationMirror annotationMirror = (AnnotationMirror) iterator
+ .next();
+
+ final String annotationType = annotationMirror.getAnnotationType().toString();
+
+ if ( annotationType.equals(javax.persistence.Id.class.getName()) ||
+ annotationType.equals(javax.persistence.EmbeddedId.class.getName()))
+ {
+ if(element.getKind()==ElementKind.FIELD) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+
+ static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+ static {
+ COLLECTIONS.put("java.util.Collection", "javax.jpa.metamodel.Collection");
+ COLLECTIONS.put("java.util.Set", "javax.jpa.metamodel.Set");
+ COLLECTIONS.put("java.util.List", "javax.jpa.metamodel.List");
+ COLLECTIONS.put("java.util.Map", "javax.jpa.metamodel.Map");
+ }
+
+ class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
+
+ MetaEntity parent;
+
+ TypeVisitor(MetaEntity parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ protected MetaMember defaultAction(TypeMirror e, Element p) {
+ //System.out.println("Default action for: " + e + " on " + p);
+ //new Exception().printStackTrace();
+ return super.defaultAction(e, p);
+ }
+ @Override
+ public MetaMember visitPrimitive(PrimitiveType t, Element p) {
+ return new MetaAttribute(parent, p, TypeUtils.toTypeString(t));
+ }
+
+
+
+ @Override
+ public MetaMember visitDeclared(DeclaredType t, Element p) {
+ TypeElement e = (TypeElement) pe.getTypeUtils().asElement(t);
+
+ String collection = COLLECTIONS.get(e.getQualifiedName().toString()); // WARNING: .toString() is necessary here since Name equals does not compare to String
+ if(collection!=null) {
+ if(collection.equals("javax.jpa.metamodel.Map")) {
+ return new MetaMap(parent, p, collection, getKeyType(t), getElementType(t));
+ } else {
+ return new MetaCollection(parent, p, collection, getElementType(t));
+ }
+ } else {
+ return new MetaAttribute(parent, p, e.getQualifiedName().toString());
+ }
+ }
+
+
+
+ @Override
+ public MetaMember visitExecutable(ExecutableType t, Element p) {
+ String string = p.getSimpleName().toString();
+
+ // TODO: implement proper property get/is/boolean detection
+ if(string.startsWith("get") || string.startsWith("is")) {
+ TypeMirror returnType = t.getReturnType();
+
+ return returnType.accept(this, p);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public String generateImports() {
+ return importContext.generateImports();
+ }
+
+ @Override
+ public String importType(String fqcn) {
+ return importContext.importType(fqcn);
+ }
+
+ @Override
+ 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,19 @@
+package org.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Element;
+
+public class MetaMap extends MetaCollection {
+
+ private final String keyType;
+
+ public MetaMap(MetaEntity parent, Element element, String collectionType,
+ String keyType, String elementType) {
+ super(parent, element, collectionType, elementType);
+ this.keyType = keyType;
+ }
+
+ public String getDeclarationString() {
+ return "public static " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,52 @@
+package org.jboss.jpa.metamodel.ap;
+
+import java.beans.Introspector;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+
+public abstract class MetaMember {
+
+ final protected Element element;
+ final protected MetaEntity parent;
+ final protected ProcessingEnvironment pe;
+ private final String type;
+
+ public MetaMember(MetaEntity parent, Element element, String type) {
+ this.element = element;
+ this.parent = parent;
+ this.type = type;
+ this.pe = parent.pe;
+ }
+
+ public String getDeclarationString() {
+ return "public static " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
+ }
+
+ protected Name getPropertyName() {
+ if(element.getKind()==ElementKind.FIELD) {
+ return element.getSimpleName();
+ } else if (element.getKind()==ElementKind.METHOD) {
+
+ String name = element.getSimpleName().toString();
+ if(name.startsWith("get")) {
+ return pe.getElementUtils().getName(Introspector.decapitalize(name.substring("get".length())));
+ } else if(name.startsWith("is")) {
+ return (pe.getElementUtils().getName(Introspector.decapitalize(name.substring("is".length()))));
+ }
+ return pe.getElementUtils().getName(Introspector.decapitalize(name));
+ } else {
+ return pe.getElementUtils().getName(element.getSimpleName() + "/* " + element.getKind() + " */");
+ }
+ }
+
+ abstract protected String getMetaType();
+
+
+ protected String getTypeDeclaration() {
+ return type;
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,33 @@
+package org.jboss.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();
+ }
+}
Property changes on: workspace/max/jpaap/test
___________________________________________________________________
Name: svn:ignore
+ build
bin
Added: workspace/max/jpaap/test/src/Test.java
===================================================================
--- workspace/max/jpaap/test/src/Test.java (rev 0)
+++ workspace/max/jpaap/test/src/Test.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,145 @@
+import static javax.jpa.criteria.JoinType.*;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Set;
+
+import javax.jpa.criteria.Expression;
+import javax.jpa.criteria.Join;
+import javax.jpa.criteria.ListJoin;
+import javax.jpa.criteria.Path;
+import javax.jpa.criteria.Query;
+import javax.jpa.criteria.QueryBuilder;
+import javax.jpa.criteria.Root;
+
+import model.metamodel.Item_;
+import model.metamodel.Order_;
+import model.metamodel.Product_;
+import model.metamodel.Shop_;
+import model.Item;
+import model.Order;
+import model.Product;
+
+/**
+ * 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() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(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.ascending(price), qb.descending(date) );
+ }
+
+ public void testUntypesafe() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(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.ascending(price), qb.descending(date) );
+ }
+
+ /**
+ * Navigation by joining
+ */
+ public void test2() {
+ Query q = qb.create();
+
+ Root<Product> product = q.addRoot(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() {
+ Query q = qb.create();
+
+ Root<Item> item = q.addRoot(Item.class);
+ Join<Item, Order> io = item.join(Item_.namedOrders);
+
+ }
+
+ /**
+ * Navigation by compound Path
+ */
+ public void test3() {
+ Query q = qb.create();
+
+ Root<Item> item = q.addRoot(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() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(Order.class);
+ ListJoin<Order, String> note = order.join(Order_.notes);
+ Expression<Set<Item>> items = order.get(Order_.items);
+ order.fetch(Order_.items, inner);
+
+ q.select(note)
+ .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
+ }
+
+ public void test4Untypesafe() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(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: workspace/max/jpaap/test/src/model/Item.java
===================================================================
--- workspace/max/jpaap/test/src/model/Item.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Item.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -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;
+
+@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: workspace/max/jpaap/test/src/model/Order.java
===================================================================
--- workspace/max/jpaap/test/src/model/Order.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Order.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,28 @@
+package model;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+@Entity
+public class Order {
+
+ @Id
+ long id;
+
+ @OneToMany
+ Set<Item> items;
+
+ boolean filled;
+ Date date;
+
+ @OneToMany
+ List<String> notes;
+
+ @ManyToOne
+ Shop shop;
+}
Added: workspace/max/jpaap/test/src/model/Product.java
===================================================================
--- workspace/max/jpaap/test/src/model/Product.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Product.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,25 @@
+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;
+
+@Entity
+public class Product {
+
+ @Id
+ long id;
+
+ String description;
+ BigDecimal price;
+
+ @ManyToOne
+ Shop shop;
+
+ @OneToMany
+ Set<Item> items;
+}
Added: workspace/max/jpaap/test/src/model/Shop.java
===================================================================
--- workspace/max/jpaap/test/src/model/Shop.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Shop.java 2009-01-16 17:44:28 UTC (rev 13098)
@@ -0,0 +1,12 @@
+package model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Shop {
+ @Id
+ long id;
+ String name;
+}
+
\ No newline at end of file
Modified: workspace/max/jpaap/test/test jpa-build.xml.launch
===================================================================
--- workspace/max/jpaap/test/test jpa-build.xml.launch 2009-01-16 17:41:29 UTC (rev 13097)
+++ workspace/max/jpaap/test/test jpa-build.xml.launch 2009-01-16 17:44:28 UTC (rev 13098)
@@ -12,7 +12,7 @@
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jre6"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jdk-1.6.0_10"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/test/jpa-build.xml}"/>
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
15 years, 12 months
JBoss Tools SVN: r13094 - workspace/max/jpaap/test.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-01-16 12:25:48 -0500 (Fri, 16 Jan 2009)
New Revision: 13094
Modified:
workspace/max/jpaap/test/test jpa-build.xml.launch
Log:
fix space
Modified: workspace/max/jpaap/test/test jpa-build.xml.launch
===================================================================
--- workspace/max/jpaap/test/test jpa-build.xml.launch 2009-01-16 17:24:59 UTC (rev 13093)
+++ workspace/max/jpaap/test/test jpa-build.xml.launch 2009-01-16 17:25:48 UTC (rev 13094)
@@ -12,7 +12,7 @@
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jdk-1.6.0_10"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jre6"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/test/jpa-build.xml}"/>
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
15 years, 12 months
JBoss Tools SVN: r13093 - in workspace/max/jpaap: test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-01-16 12:24:59 -0500 (Fri, 16 Jan 2009)
New Revision: 13093
Removed:
workspace/max/jpaap/jpaap/src/
workspace/max/jpaap/test/.apt_generated/
workspace/max/jpaap/test/build/
workspace/max/jpaap/test/src/
Log:
remove bin/temp files
15 years, 12 months
JBoss Tools SVN: r13092 - workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-01-16 12:17:08 -0500 (Fri, 16 Jan 2009)
New Revision: 13092
Added:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity$TypeVisitor.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.class
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.class
Removed:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java
Log:
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,23 +0,0 @@
-package org.jboss.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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,160 +0,0 @@
-package org.jboss.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;
-
- 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,152 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import static javax.lang.model.SourceVersion.RELEASE_6;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Generated;
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.FilerException;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-import javax.tools.FileObject;
-
-@SupportedAnnotationTypes("javax.persistence.Entity")
-@SupportedSourceVersion(RELEASE_6)
-public class JPAMetaModelEntityProcessor extends AbstractProcessor {
-
- public JPAMetaModelEntityProcessor() {
-
- }
-
- /**
- * 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) {
-
-
- if(aRoundEnvironment.processingOver()) { // No need to run since all our output needs to be considered
- return false;
- }
-
- Set<? extends Element> elements = aRoundEnvironment.getRootElements();
-
- 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(MetaEntity entity) {
-
- try {
- Name metaModelPackage = entity.getPackageName();
-
-
- StringBuffer body = generateBody(entity);
-
- FileObject fo = processingEnv.getFiler().createSourceFile(
- metaModelPackage + "." + entity.getSimpleName() + "_",
- entity.getOriginalElement());
- 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(MetaEntity 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.jpa.metamodel.TypesafeMetamodel"));
-
- pw.println("public abstract class " + entity.getSimpleName() + "_" + " {");
-
- pw.println();
-
- List<MetaMember> members = entity.getMembers();
-
- for (MetaMember metaMember : members) {
- pw.println( " " + metaMember.getDeclarationString() );
- }
- pw.println();
- pw.println("}");
- return sw.getBuffer();
- } finally {
- if (pw!=null) pw.close();
- }
-
-
- }
-
-}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,33 +0,0 @@
-package org.jboss.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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,16 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import javax.lang.model.element.Element;
-
-public class MetaAttribute extends MetaMember {
-
- public MetaAttribute(MetaEntity parent, Element element, String type) {
- super(parent, element, type);
- }
-
- @Override
- protected String getMetaType() {
- return "javax.jpa.metamodel.Attribute";
- }
-
-}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,22 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import javax.lang.model.element.Element;
-
-
-public class MetaCollection extends MetaMember {
-
- private String collectionType;
-
-
- public MetaCollection(MetaEntity parent, Element element, String collectionType, String elementType) {
- super(parent, element, elementType);
- this.collectionType = collectionType;
- }
-
- @Override
- protected String getMetaType() {
- return collectionType;
- }
-
-
-}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity$TypeVisitor.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity$TypeVisitor.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,224 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.ExecutableType;
-import javax.lang.model.type.PrimitiveType;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.SimpleTypeVisitor6;
-import javax.tools.Diagnostic.Kind;
-
-public class MetaEntity implements ImportContext {
-
- 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 Name getSimpleName() {
- return element.getSimpleName();
- }
-
- public Element getOriginalElement() {
- return element;
- }
-
- public Name getQualifiedName() {
- return element.getQualifiedName();
- }
-
- public Name getPackageName() {
- PackageElement packageOf = pe.getElementUtils().getPackageOf(element);
- return pe.getElementUtils().getName(packageOf.getQualifiedName() + ".metamodel");
- }
-
- public List<MetaMember> getMembers() {
-
- List<MetaMember> members = new ArrayList<MetaMember>();
-
- if(useFields()) {
-
- List<? extends Element> myMembers = ElementFilter.fieldsIn(element.getEnclosedElements());
-
- System.out.println("Scanning " + myMembers.size() + " field s for " + element.toString());
-
- for (Element mymember : myMembers) {
-
- MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
- if(result!=null) {
- members.add(result);
- } else {
- pe.getMessager().printMessage(Kind.WARNING, "Could not find valid info for JPA property", mymember);
- }
- }
-
- } else {
-
-
- List<? extends Element> myMembers = ElementFilter.methodsIn(element.getEnclosedElements());
-
- System.out.println("Scanning " + myMembers.size() + " methods for " + element.toString());
- for (Element mymember : myMembers) {
-
- MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
- if(result!=null) {
- members.add(result);
- } else {
- //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA property", mymember);
- }
- }
-
- }
-
- if(members.size()==0) {
- pe.getMessager().printMessage(Kind.WARNING, "No properties found on " + element, element);
- }
- return members;
- }
-
-
- //TODO: Find more efficient way to identify wether we should use fields or properties
- private boolean useFields() {
- List<? extends Element> myMembers = element.getEnclosedElements();
- for (Element element : myMembers) {
- List<? extends AnnotationMirror> entityAnnotations =
- pe.getElementUtils().getAllAnnotationMirrors(element);
-
- for (Iterator<?> iterator = entityAnnotations.iterator(); iterator
- .hasNext();) {
- AnnotationMirror annotationMirror = (AnnotationMirror) iterator
- .next();
-
- final String annotationType = annotationMirror.getAnnotationType().toString();
-
- if ( annotationType.equals(javax.persistence.Id.class.getName()) ||
- annotationType.equals(javax.persistence.EmbeddedId.class.getName()))
- {
- if(element.getKind()==ElementKind.FIELD) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
-
-
- static Map<String, String> COLLECTIONS = new HashMap<String, String>();
- static {
- COLLECTIONS.put("java.util.Collection", "javax.jpa.metamodel.Collection");
- COLLECTIONS.put("java.util.Set", "javax.jpa.metamodel.Set");
- COLLECTIONS.put("java.util.List", "javax.jpa.metamodel.List");
- COLLECTIONS.put("java.util.Map", "javax.jpa.metamodel.Map");
- }
-
- class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
-
- MetaEntity parent;
-
- TypeVisitor(MetaEntity parent) {
- this.parent = parent;
- }
-
- @Override
- protected MetaMember defaultAction(TypeMirror e, Element p) {
- //System.out.println("Default action for: " + e + " on " + p);
- //new Exception().printStackTrace();
- return super.defaultAction(e, p);
- }
- @Override
- public MetaMember visitPrimitive(PrimitiveType t, Element p) {
- return new MetaAttribute(parent, p, TypeUtils.toTypeString(t));
- }
-
-
-
- @Override
- public MetaMember visitDeclared(DeclaredType t, Element p) {
- TypeElement e = (TypeElement) pe.getTypeUtils().asElement(t);
-
- String collection = COLLECTIONS.get(e.getQualifiedName().toString()); // WARNING: .toString() is necessary here since Name equals does not compare to String
- if(collection!=null) {
- if(collection.equals("javax.jpa.metamodel.Map")) {
- return new MetaMap(parent, p, collection, getKeyType(t), getElementType(t));
- } else {
- return new MetaCollection(parent, p, collection, getElementType(t));
- }
- } else {
- return new MetaAttribute(parent, p, e.getQualifiedName().toString());
- }
- }
-
-
-
- @Override
- public MetaMember visitExecutable(ExecutableType t, Element p) {
- String string = p.getSimpleName().toString();
-
- // TODO: implement proper property get/is/boolean detection
- if(string.startsWith("get") || string.startsWith("is")) {
- TypeMirror returnType = t.getReturnType();
-
- return returnType.accept(this, p);
- } else {
- return null;
- }
- }
- }
-
- @Override
- public String generateImports() {
- return importContext.generateImports();
- }
-
- @Override
- public String importType(String fqcn) {
- return importContext.importType(fqcn);
- }
-
- @Override
- 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,19 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import javax.lang.model.element.Element;
-
-public class MetaMap extends MetaCollection {
-
- private final String keyType;
-
- public MetaMap(MetaEntity parent, Element element, String collectionType,
- String keyType, String elementType) {
- super(parent, element, collectionType, elementType);
- this.keyType = keyType;
- }
-
- public String getDeclarationString() {
- return "public static " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
- }
-
-}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,52 +0,0 @@
-package org.jboss.jpa.metamodel.ap;
-
-import java.beans.Introspector;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Name;
-
-public abstract class MetaMember {
-
- final protected Element element;
- final protected MetaEntity parent;
- final protected ProcessingEnvironment pe;
- private final String type;
-
- public MetaMember(MetaEntity parent, Element element, String type) {
- this.element = element;
- this.parent = parent;
- this.type = type;
- this.pe = parent.pe;
- }
-
- public String getDeclarationString() {
- return "public static " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
- }
-
- protected Name getPropertyName() {
- if(element.getKind()==ElementKind.FIELD) {
- return element.getSimpleName();
- } else if (element.getKind()==ElementKind.METHOD) {
-
- String name = element.getSimpleName().toString();
- if(name.startsWith("get")) {
- return pe.getElementUtils().getName(Introspector.decapitalize(name.substring("get".length())));
- } else if(name.startsWith("is")) {
- return (pe.getElementUtils().getName(Introspector.decapitalize(name.substring("is".length()))));
- }
- return pe.getElementUtils().getName(Introspector.decapitalize(name));
- } else {
- return pe.getElementUtils().getName(element.getSimpleName() + "/* " + element.getKind() + " */");
- }
- }
-
- abstract protected String getMetaType();
-
-
- protected String getTypeDeclaration() {
- return type;
- }
-
-}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.class
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java 2009-01-16 17:15:21 UTC (rev 13091)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java 2009-01-16 17:17:08 UTC (rev 13092)
@@ -1,33 +0,0 @@
-package org.jboss.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();
- }
-}
15 years, 12 months
JBoss Tools SVN: r13090 - in workspace/max: jpaap and 45 other directories.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-01-16 11:48:05 -0500 (Fri, 16 Jan 2009)
New Revision: 13090
Added:
workspace/max/jpaap/
workspace/max/jpaap/javax.persistence/
workspace/max/jpaap/javax.persistence/.classpath
workspace/max/jpaap/javax.persistence/.project
workspace/max/jpaap/javax.persistence/META-INF/
workspace/max/jpaap/javax.persistence/META-INF/MANIFEST.MF
workspace/max/jpaap/javax.persistence/bin/
workspace/max/jpaap/javax.persistence/bin/javax/
workspace/max/jpaap/javax.persistence/bin/javax/jpa/
workspace/max/jpaap/javax.persistence/bin/javax/jpa/criteria/
workspace/max/jpaap/javax.persistence/bin/javax/jpa/metamodel/
workspace/max/jpaap/javax.persistence/bin/javax/persistence/
workspace/max/jpaap/javax.persistence/bin/javax/persistence/spi/
workspace/max/jpaap/javax.persistence/build.properties
workspace/max/jpaap/javax.persistence/build.xml
workspace/max/jpaap/javax.persistence/jpa.jar
workspace/max/jpaap/javax.persistence/jpa.jardesc
workspace/max/jpaap/javax.persistence/readme.txt
workspace/max/jpaap/javax.persistence/src/
workspace/max/jpaap/javax.persistence/src/javax/
workspace/max/jpaap/javax.persistence/src/javax/jpa/
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java
workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/
workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java
workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java
workspace/max/jpaap/jpaap/
workspace/max/jpaap/jpaap/.classpath
workspace/max/jpaap/jpaap/.project
workspace/max/jpaap/jpaap/META-INF/
workspace/max/jpaap/jpaap/META-INF/MANIFEST.MF
workspace/max/jpaap/jpaap/bin/
workspace/max/jpaap/jpaap/bin/META-INF/
workspace/max/jpaap/jpaap/bin/META-INF/services/
workspace/max/jpaap/jpaap/bin/META-INF/services/javax.annotation.processing.Processor
workspace/max/jpaap/jpaap/bin/org/
workspace/max/jpaap/jpaap/bin/org/jboss/
workspace/max/jpaap/jpaap/bin/org/jboss/jpa/
workspace/max/jpaap/jpaap/bin/org/jboss/jpa/metamodel/
workspace/max/jpaap/jpaap/bin/org/jboss/jpa/metamodel/ap/
workspace/max/jpaap/jpaap/build.properties
workspace/max/jpaap/jpaap/build.xml
workspace/max/jpaap/jpaap/jpaap.jar
workspace/max/jpaap/jpaap/jpaap.jardesc
workspace/max/jpaap/jpaap/readme.txt
workspace/max/jpaap/jpaap/src/
workspace/max/jpaap/jpaap/src/META-INF/
workspace/max/jpaap/jpaap/src/META-INF/services/
workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor
workspace/max/jpaap/jpaap/src/org/
workspace/max/jpaap/jpaap/src/org/jboss/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java
workspace/max/jpaap/org.jboss.jpa.metamodel/
workspace/max/jpaap/org.jboss.jpa.metamodel/.classpath
workspace/max/jpaap/org.jboss.jpa.metamodel/.project
workspace/max/jpaap/org.jboss.jpa.metamodel/.settings/
workspace/max/jpaap/org.jboss.jpa.metamodel/.settings/org.eclipse.jdt.core.prefs
workspace/max/jpaap/org.jboss.jpa.metamodel/META-INF/
workspace/max/jpaap/org.jboss.jpa.metamodel/META-INF/MANIFEST.MF
workspace/max/jpaap/org.jboss.jpa.metamodel/bin/
workspace/max/jpaap/org.jboss.jpa.metamodel/build.properties
workspace/max/jpaap/org.jboss.jpa.metamodel/plugin.xml
workspace/max/jpaap/org.jboss.jpa.metamodel/src/
workspace/max/jpaap/test/
workspace/max/jpaap/test/.apt_generated/
workspace/max/jpaap/test/.classpath
workspace/max/jpaap/test/.factorypath
workspace/max/jpaap/test/.project
workspace/max/jpaap/test/.settings/
workspace/max/jpaap/test/.settings/org.eclipse.jdt.apt.core.prefs
workspace/max/jpaap/test/.settings/org.eclipse.jdt.core.prefs
workspace/max/jpaap/test/bin/
workspace/max/jpaap/test/bin/model/
workspace/max/jpaap/test/bin/model/metamodel/
workspace/max/jpaap/test/build.xml
workspace/max/jpaap/test/build/
workspace/max/jpaap/test/build/classes/
workspace/max/jpaap/test/build/classes/model/
workspace/max/jpaap/test/build/classes/model/metamodel/
workspace/max/jpaap/test/build/classes/model/metamodel/Item_.java
workspace/max/jpaap/test/build/classes/model/metamodel/Order_.java
workspace/max/jpaap/test/build/classes/model/metamodel/Product_.java
workspace/max/jpaap/test/build/classes/model/metamodel/Shop_.java
workspace/max/jpaap/test/gen-src/
workspace/max/jpaap/test/goal/
workspace/max/jpaap/test/goal/metamodel/
workspace/max/jpaap/test/goal/metamodel/Item_.java
workspace/max/jpaap/test/goal/metamodel/Order_.java
workspace/max/jpaap/test/goal/metamodel/Product_.java
workspace/max/jpaap/test/goal/metamodel/Shop_.java
workspace/max/jpaap/test/jpa-build.xml
workspace/max/jpaap/test/lib/
workspace/max/jpaap/test/readme.txt
workspace/max/jpaap/test/src/
workspace/max/jpaap/test/src/Test.java
workspace/max/jpaap/test/src/model/
workspace/max/jpaap/test/src/model/Item.java
workspace/max/jpaap/test/src/model/Order.java
workspace/max/jpaap/test/src/model/Product.java
workspace/max/jpaap/test/src/model/Shop.java
workspace/max/jpaap/test/test jpa-build.xml.launch
Log:
Experiment with Java 6 Annotation Processor
Added: workspace/max/jpaap/javax.persistence/.classpath
===================================================================
--- workspace/max/jpaap/javax.persistence/.classpath (rev 0)
+++ workspace/max/jpaap/javax.persistence/.classpath 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/max/jpaap/javax.persistence/.project
===================================================================
--- workspace/max/jpaap/javax.persistence/.project (rev 0)
+++ workspace/max/jpaap/javax.persistence/.project 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>javax.persistence</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
Added: workspace/max/jpaap/javax.persistence/META-INF/MANIFEST.MF
===================================================================
--- workspace/max/jpaap/javax.persistence/META-INF/MANIFEST.MF (rev 0)
+++ workspace/max/jpaap/javax.persistence/META-INF/MANIFEST.MF 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Persistence
+Bundle-SymbolicName: javax.persistence
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: workspace/max/jpaap/javax.persistence/build.properties
===================================================================
--- workspace/max/jpaap/javax.persistence/build.properties (rev 0)
+++ workspace/max/jpaap/javax.persistence/build.properties 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,3 @@
+source.. = src/
+bin.includes = META-INF/,\
+ .
Added: workspace/max/jpaap/javax.persistence/build.xml
===================================================================
--- workspace/max/jpaap/javax.persistence/build.xml (rev 0)
+++ workspace/max/jpaap/javax.persistence/build.xml 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- WARNING: Eclipse auto-generated file.
+ Any modifications will be overwritten.
+ To include a user specific buildfile here, simply create one in the same
+ directory with the processing instruction <?eclipse.ant.import?>
+ as the first entry and export the buildfile again. -->
+<project basedir="." default="build" name="javax.persistence">
+ <property environment="env"/>
+ <property name="jpaap.location" value="../jpaap"/>
+ <property name="test.location" value="../test"/>
+ <property name="debuglevel" value="source,lines,vars"/>
+ <property name="target" value="1.6"/>
+ <property name="source" value="1.6"/>
+ <path id="Plug-in Dependencies.libraryclasspath"/>
+ <path id="javax.persistence.classpath">
+ <pathelement location="classes"/>
+ <pathelement location="bin"/>
+ <path refid="Plug-in Dependencies.libraryclasspath"/>
+ </path>
+ <target name="init">
+ <mkdir dir="bin"/>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="src" excludes="**/*.launch, **/*.java"/>
+ </copy>
+ </target>
+ <target name="clean">
+ <delete dir="bin"/>
+ </target>
+ <target depends="clean" name="cleanall"/>
+ <target depends="build-subprojects,build-project" name="build"/>
+ <target name="build-subprojects"/>
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="src"/>
+ <classpath refid="javax.persistence.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects">
+ <ant antfile="${jpaap.location}/build.xml" inheritAll="false" target="clean"/>
+ <ant antfile="${jpaap.location}/build.xml" inheritAll="false" target="build"/>
+ <ant antfile="${test.location}/build.xml" inheritAll="false" target="clean"/>
+ <ant antfile="${test.location}/build.xml" inheritAll="false" target="build"/>
+ </target>
+</project>
Added: workspace/max/jpaap/javax.persistence/jpa.jar
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/javax.persistence/jpa.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/max/jpaap/javax.persistence/jpa.jardesc
===================================================================
--- workspace/max/jpaap/javax.persistence/jpa.jardesc (rev 0)
+++ workspace/max/jpaap/javax.persistence/jpa.jardesc 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
+<jardesc>
+ <jar path="javax.persistence/jpa.jar"/>
+ <options buildIfNeeded="true" compress="true" descriptionLocation="/javax.persistence/jpa.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
+ <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
+ <selectedProjects/>
+ <manifest generateManifest="false" manifestLocation="/javax.persistence/META-INF/MANIFEST.MF" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
+ <sealing sealJar="false">
+ <packagesToSeal/>
+ <packagesToUnSeal/>
+ </sealing>
+ </manifest>
+ <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
+ <javaElement handleIdentifier="=javax.persistence/src"/>
+ <folder path="/javax.persistence/META-INF"/>
+ </selectedElements>
+ <fatjar builder="org.eclipse.jdt.ui.plain_jar_builder" launchConfig=""/>
+</jardesc>
Added: workspace/max/jpaap/javax.persistence/readme.txt
===================================================================
--- workspace/max/jpaap/javax.persistence/readme.txt (rev 0)
+++ workspace/max/jpaap/javax.persistence/readme.txt 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,5 @@
+This project simply contain the src for JPA API + src for the new Criteria API.
+
+Use jpa.jar directly or simply depend on the project.
+
+To regenerate the jar Right click on jpa.jardesc and choose "Create Jar"
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractCollectionJoin.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.AbstractCollection;
+
+/**
+ * A join to a collection
+ */
+public interface AbstractCollectionJoin<Z, C, E>
+ extends Join<Z, E> {
+ AbstractCollection<? super Z, C, E> getModel();
+
+ //TODO: do we need these????
+ /*
+ Predicate isEmpty();
+ Predicate isNotEmpty();
+
+ Expression<Integer> size();
+
+ Predicate isMember(E elem);
+ Predicate isNotMember(E elem);
+
+ Predicate isMember(Expression<E> elem);
+ Predicate isNotMember(Expression<E> elem);
+ */
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/AbstractQuery.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,36 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.jpa.metamodel.Entity;
+
+/**
+ * All queries have:
+ * a set of root bound entities (which may in turn own joins)
+ * a conjunction of restrictions
+ * an ordered list of orders
+ */
+public interface AbstractQuery {
+
+ <X> Root<X> addRoot(Entity<X> entity);
+ <X> Root<X> addRoot(Class<X> entityClass);
+ Set<Root<?>> getRoots();
+
+ AbstractQuery where(Expression<Boolean> restriction);
+ AbstractQuery where(Predicate... restrictions);
+ AbstractQuery group(Expression<?>... grouping);
+ AbstractQuery having(Expression<Boolean> restriction);
+ AbstractQuery having(Predicate... restrictions);
+ AbstractQuery order(Order... o);
+ AbstractQuery distinct(boolean distinct);
+
+ List<Order> getOrderList();
+ List<Expression<?>> getGroupList();
+ Predicate getRestriction();
+ Predicate getGroupRestriction();
+ boolean isDistinct();
+
+ <U> Subquery<U> subquery(Class<U> type);
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/CollectionJoin.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+import java.util.Collection;
+
+public interface CollectionJoin<Z, E>
+ extends AbstractCollectionJoin<Z, Collection<E>, E> {
+ javax.jpa.metamodel.Collection<? super Z, E> getModel();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Expression.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+public interface Expression<T> extends Selection {
+ Class<T> getJavaType();
+
+ Predicate isNull();
+ Predicate isNotNull();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Fetch.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,12 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Member;
+
+/**
+ * Represents a fetched association or attribute
+ */
+public interface Fetch<Z, X> extends FetchParent<Z, X> {
+ Member<? extends Z, X> getMember();
+ FetchParent<?, Z> getParent();
+ JoinType getJoinType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/FetchParent.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.AbstractCollection;
+import javax.jpa.metamodel.Attribute;
+
+/**
+ * Represents an element of the from clause which may
+ * function as the parent of Fetches.
+ */
+public interface FetchParent<Z, X> {
+ java.util.Set<Fetch<X, ?>> getFetches();
+
+ <Y> Fetch<X, Y> fetch(Attribute<? super X, Y> assoc);
+ <Y> Fetch<X, Y> fetch(AbstractCollection<? super X, ?, Y> assoc);
+
+ <Y> Fetch<X, Y> fetch(Attribute<? super X, Y> assoc, JoinType jt);
+ <Y> Fetch<X, Y> fetch(AbstractCollection<? super X, ?, Y> assoc, JoinType jt);
+
+ //Untypesafe:
+
+ <Y> Fetch<X, Y> fetch(String assocName);
+ <Y> Fetch<X, Y> fetch(String assocName, JoinType jt);
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/From.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,47 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Collection;
+import javax.jpa.metamodel.List;
+import javax.jpa.metamodel.Map;
+import javax.jpa.metamodel.Set;
+
+/**
+ * Represents a bound type, usually an entity that appears in
+ * the from clause, but may also be an embeddable belonging to
+ * an entity in the from clause. A factory for Joins of associations,
+ * embeddables and collections belonging to the type, and for Paths
+ * of attributes belonging to the type.
+ */
+public interface From<Z, X> extends Path<X>, FetchParent<Z, X> {
+ java.util.Set<Join<X, ?>> getJoins();
+
+ <Y> Join<X, Y> join(Attribute<? super X, Y> attribute);
+ <Y> Join<X, Y> join(Attribute<? super X, Y> attribute, JoinType jt);
+
+ <Y> CollectionJoin<X, Y> join(Collection<? super X, Y> collection);
+ <Y> SetJoin<X, Y> join(Set<? super X, Y> set);
+ <Y> ListJoin<X, Y> join(List<? super X, Y> list);
+ <K, V> MapJoin<X, K, V> join(Map<? super X, K, V> map);
+
+ <Y> CollectionJoin<X, Y> join(Collection<? super X, Y> collection, JoinType jt);
+ <Y> SetJoin<X, Y> join(Set<? super X, Y> set, JoinType jt);
+ <Y> ListJoin<X, Y> join(List<? super X, Y> list, JoinType jt);
+ <K, V> MapJoin<X, K, V> join(Map<? super X, K, V> map, JoinType jt);
+
+ Expression<Class<? extends X>> type();
+
+ //Untypesafe:
+
+ <W, Y> Join<W, Y> join(String attributeName);
+ <W, Y> CollectionJoin<W, Y> joinCollection(String attributeName);
+ <W, Y> SetJoin<W, Y> joinSet(String attributeName);
+ <W, Y> ListJoin<W, Y> joinList(String attributeName);
+ <W, K, V> MapJoin<W, K, V> joinMap(String attributeName);
+
+ <W, Y> Join<W, Y> join(String attributeName, JoinType jt);
+ <W, Y> CollectionJoin<W, Y> joinCollection(String attributeName, JoinType jt);
+ <W, Y> SetJoin<W, Y> joinSet(String attributeName, JoinType jt);
+ <W, Y> ListJoin<W, Y> joinList(String attributeName, JoinType jt);
+ <W, K, V> MapJoin<W, K, V> joinMap(String attributeName, JoinType jt);
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Join.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,12 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Member;
+
+/**
+ * A join to an entity or embeddable type
+ */
+public interface Join<Z, X> extends From<Z, X> {
+ Member<? extends Z, X> getMember();
+ From<?, Z> getParent();
+ JoinType getJoinType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/JoinType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+/**
+ * The three types of joins
+ */
+public enum JoinType {
+ inner, left, right
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/ListJoin.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,9 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+
+public interface ListJoin<Z, E>
+ extends AbstractCollectionJoin<Z, List<E>, E> {
+ javax.jpa.metamodel.List<? super Z, E> getModel();
+ Expression<Integer> index();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/MapJoin.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,13 @@
+package javax.jpa.criteria;
+
+import java.util.Map;
+
+public interface MapJoin<Z, K, V>
+ extends AbstractCollectionJoin<Z, Map<K, V>, V> {
+ javax.jpa.metamodel.Map<? super Z, K, V> getModel();
+ Join<Map<K, V>, K> joinKey();
+ Join<Map<K, V>, K> joinKey(JoinType jt);
+ Path<K> key();
+ Path<V> value(); //Unnecessary - just returns this
+ Expression<Map.Entry<K, V>> entry();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Order.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,10 @@
+package javax.jpa.criteria;
+
+/**
+ * An object that imposes an order upon the query results
+ */
+public interface Order {
+ void reverse();
+ boolean isAscending();
+ <T extends Comparable<T>> Expression<T> getExpression();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Path.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.AbstractCollection;
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Bindable;
+import javax.jpa.metamodel.Map;
+
+/**
+ * Represents a simple or compound attribute path from a
+ * bound type or collection, and is a "primitive" expression.
+ */
+public interface Path<X> extends Expression<X> {
+ Bindable<X> getModel(); //TODO: what does this return for a collection key, value? null?
+ Path<?> getParentPath();
+
+ <Y> Path<Y> get(Attribute<? super X, Y> model);
+ <E, C extends java.util.Collection<E>> Expression<C> get(AbstractCollection<X, C, E> collection);
+ <K, V, M extends java.util.Map<K, V>> Expression<M> get(Map<X, K, V> collection);
+
+ //Untypesafe:
+
+ <Y> Path<Y> get(String attName);
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Predicate.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,19 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+
+/**
+ * A conjunction or disjunction of restrictions
+ */
+public interface Predicate extends Expression<Boolean> {
+
+ public static enum BooleanOperator {
+ and, or
+ }
+
+ BooleanOperator getOperator();
+ boolean isNegated();
+ List<Expression<Boolean>> getExpressions();
+ Predicate add(Expression<Boolean> s);
+ Predicate negate();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Query.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+package javax.jpa.criteria;
+
+import java.util.List;
+
+
+/**
+ * A top-level query has an ordered list of selections
+ */
+public interface Query extends AbstractQuery {
+
+ Query select(Selection... selections);
+
+ //override the return type only:
+ Query where(Expression<Boolean> restriction);
+ Query where(Predicate... restrictions);
+ Query group(Expression<?>... grouping);
+ Query having(Expression<Boolean> restriction);
+ Query order(Order... o);
+ Query distinct(boolean distinct);
+
+ List<Selection> getSelectionList();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/QueryBuilder.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,244 @@
+package javax.jpa.criteria;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Factory object for queries, orders, restrictions, expressions.
+ * The factory methods are all completely typesafe. Note that
+ * Predicate is used instead of Expression<Boolean> in this
+ * API in order to work around the fact that Java generics are
+ * not compatible with varags.
+ */
+public interface QueryBuilder {
+ Query create();
+
+ //select new Foo(...) equivalent:
+
+ <Y> Selection select(Class<Y> result, Selection... selections);
+
+ //ordering:
+ //unfortunately, Number does not implement Comparable :-(
+
+ <Y extends Comparable<Y>> Order ascending(Expression<? extends Y> x);
+ <Y extends Comparable<Y>> Order descending(Expression<? extends Y> x);
+
+ Order asc(Expression<? extends Number> x);
+ Order desc(Expression<? extends Number> x);
+
+ //aggregate functions:
+
+ <N extends Number> Expression<N> avg(Expression<N> x);
+ <N extends Number> Expression<N> sum(Expression<N> x);
+ <N extends Number> Expression<N> max(Expression<N> x);
+ <N extends Number> Expression<N> min(Expression<N> x);
+
+ Expression<Integer> count(Expression<?> x);
+ Expression<Integer> countDistinct(Expression<?> x);
+
+ //subqueries:
+
+ Predicate exists(Subquery<?> subquery);
+ <Y> Expression<Y> all(Subquery<Y> subquery);
+ <Y> Expression<Y> none(Subquery<Y> subquery);
+ <Y> Expression<Y> some(Subquery<Y> subquery);
+
+ //boolean functions:
+
+ Predicate and(Expression<Boolean> x, Expression<Boolean> y);
+ Predicate or(Expression<Boolean> x, Expression<Boolean> y);
+ Predicate and(Predicate... restrictions);
+ Predicate or(Predicate... restrictions);
+ Predicate not(Expression<Boolean> restriction);
+
+ Predicate conjunction();
+ Predicate disjunction();
+
+ //turn Expression<Boolean> into a Predicate
+ //useful for use with varargs methods
+ Predicate isTrue(Expression<Boolean> x);
+ Predicate isFalse(Expression<Boolean> x);
+
+ //equality:
+
+ Predicate equal(Expression<?> x, Expression<?> y);
+ Predicate notEqual(Expression<?> x, Expression<?> y);
+
+ Predicate equal(Expression<?> x, Object y);
+ Predicate notEqual(Expression<?> x, Object y);
+
+ //Predicate equal(Expression<?> x, Expression<?> y);
+ //Predicate notEqual(Expression<?> x, Expression<?> y);
+ //<Y> Predicate equal(Expression<Y> x, Y y);
+ //<Y> Predicate notEqual(Expression<Y> x, Y y);
+ //Predicate eq(Expression<? extends Number> x, Expression<? extends Number> y);
+ //Predicate ne(Expression<? extends Number> x, Expression<? extends Number> y);
+ //Predicate eq(Expression<? extends Number> x, Number y);
+ //Predicate ne(Expression<? extends Number> x, Number y);
+
+ //comparisons for generic (non-numeric) operands:
+
+ <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Expression<? extends Y> x, Expression<? extends Y> y);
+
+ <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Y y);
+ <Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Y x, Y y);
+
+ //comparisons for numeric operands:
+
+ Predicate gt(Expression<? extends Number> x, Expression<? extends Number> y);
+ Predicate lt(Expression<? extends Number> x, Expression<? extends Number> y);
+ Predicate ge(Expression<? extends Number> x, Expression<? extends Number> y);
+ Predicate le(Expression<? extends Number> x, Expression<? extends Number> y);
+
+ Predicate gt(Expression<? extends Number> x, Number y);
+ Predicate lt(Expression<? extends Number> x, Number y);
+ Predicate ge(Expression<? extends Number> x, Number y);
+ Predicate le(Expression<? extends Number> x, Number y);
+
+ //coalesce, nullif:
+
+ <Y> Expression<Y> coalesce(Expression<? extends Y> x, Expression<? extends Y> y);
+ <Y> Expression<Y> coalesce(Expression<? extends Y> x, Y y);
+
+ <Y> Expression<Y> nullif(Expression<Y> x, Expression<?> y);
+ <Y> Expression<Y> nullif(Expression<Y> x, Object y);
+
+ //numerical operations:
+
+ <N extends Number> Expression<N> neg(Expression<N> x);
+ <N extends Number> Expression<N> abs(Expression<N> x);
+
+ //TODO: support builder pattern for sums, products
+ <N extends Number> Expression<N> sum(Expression<? extends N> x, Expression<? extends N> y);
+ <N extends Number> Expression<N> prod(Expression<? extends N> x, Expression<? extends N> y);
+ <N extends Number> Expression<N> diff(Expression<? extends N> x, Expression<? extends N> y);
+ <N extends Number> Expression<N> sum(Expression<? extends N> x, N y);
+ <N extends Number> Expression<N> prod(Expression<? extends N> x, N y);
+ <N extends Number> Expression<N> diff(Expression<? extends N> x, N y);
+ <N extends Number> Expression<N> sum(N x, Expression<? extends N> y);
+ <N extends Number> Expression<N> prod(N x, Expression<? extends N> y);
+ <N extends Number> Expression<N> diff(N x, Expression<? extends N> y);
+
+ Expression<Number> quot(Expression<? extends Number> x, Expression<? extends Number> y);
+ Expression<Number> quot(Expression<? extends Number> x, Number y);
+ Expression<Number> quot(Number x, Expression<? extends Number> y);
+
+ Expression<Integer> mod(Expression<Integer> x, Expression<Integer> y);
+ Expression<Integer> mod(Expression<Integer> x, Integer y);
+ Expression<Integer> mod(Integer x, Expression<Integer> y);
+
+ Expression<Double> sqrt(Expression<? extends Number> x);
+
+ //typecasts:
+
+ Expression<Long> toLong(Expression<? extends Number> number);
+ Expression<Integer> toInteger(Expression<? extends Number> number);
+ Expression<Float> toFloat(Expression<? extends Number> number);
+ Expression<Double> toDouble(Expression<? extends Number> number);
+ Expression<BigDecimal> toBigDecimal(Expression<? extends Number> number);
+ Expression<BigInteger> toBigInteger(Expression<? extends Number> number);
+
+ Expression<String> toString(Expression<Character> character);
+
+ //almost always unnecessary:
+ <T> Expression<T> literal(T value);
+
+ //collection operations:
+
+ <C extends Collection<?>> Predicate isEmpty(Expression<C> collection);
+ <C extends Collection<?>> Predicate isNotEmpty(Expression<C> collection);
+
+ <C extends Collection<?>> Expression<Integer> size(C collection);
+
+ <E, C extends Collection<E>> Predicate isMember(E elem, C collection);
+ <E, C extends Collection<E>> Predicate isNotMember(E elem, C collection);
+
+ <E, C extends Collection<E>> Predicate isMember(Expression<E> elem, C collection);
+ <E, C extends Collection<E>> Predicate isNotMember(Expression<E> elem, C collection);
+
+ //get the values and keys collections of the Map, which may then
+ //be passed to size(), isMember(), isEmpty(), etc
+ <V, M extends Map<?, V>> Expression<Collection<V>> values(M map);
+ <K, M extends Map<K, ?>> Expression<Set<K>> keySet(M map);
+
+ //string functions:
+
+ public static enum Trimspec { leading, trailing, both }
+
+ Predicate like(Expression<String> x, Expression<String> pattern);
+ Predicate like(Expression<String> x, String pattern);
+ Predicate notLike(Expression<String> x, Expression<String> pattern);
+ Predicate notLike(Expression<String> x, String pattern);
+
+ Expression<String> concat(Expression<String> x, Expression<String> y);
+ Expression<String> concat(Expression<String> x, String y);
+ Expression<String> concat(String x, Expression<String> y);
+
+ Expression<String> substring(Expression<String> x, Expression<Integer> from);
+ Expression<String> substring(Expression<String> x, int from);
+ Expression<String> substring(Expression<String> x, Expression<Integer> from, Expression<Integer> to);
+ Expression<String> substring(Expression<String> x, int from, int to);
+
+ Expression<String> trim(Expression<Character> t, Expression<String> x);
+ Expression<String> trim(Trimspec ts, Expression<Character> t, Expression<String> x);
+ Expression<String> trim(char t, Expression<String> x);
+ Expression<String> trim(Trimspec ts, char t, Expression<String> x);
+
+ Expression<String> lower(Expression<String> x);
+ Expression<String> upper(Expression<String> x);
+ Expression<Integer> length(Expression<String> x);
+
+ Expression<Integer> locate(Expression<String> x, Expression<String> pattern);
+ Expression<Integer> locate(Expression<String> x, Expression<String> pattern, Expression<Integer> from);
+ Expression<Integer> locate(Expression<String> x, String pattern);
+ Expression<Integer> locate(Expression<String> x, String pattern, int from);
+
+ Expression<java.sql.Date> currentDate();
+ Expression<java.sql.Timestamp> currentTimestamp();
+ Expression<java.sql.Time> currentTime();
+
+ //case/in builders:
+
+ public static interface In<T> extends Expression<Boolean> {
+ Expression<T> getExpression();
+ //TODO: should we restrict the types to T?
+ In<T> value(Object value);
+ In<T> value(Expression<?> value);
+ }
+
+ <T> In<T> in(Expression<T> expression);
+
+ public static interface SimpleCase<C,R> extends Expression<R> {
+ Expression<C> getExpression();
+ SimpleCase<C, R> when(C condition, R result);
+ SimpleCase<C, R> when(C condition, Expression<R> result);
+ }
+
+ public static interface Case<R> extends Expression<R> {
+ Case<R> when(Expression<Boolean> condition, R result);
+ Case<R> when(Expression<Boolean> condition, Expression<R> result);
+ }
+
+ <C, R> SimpleCase<C,R> selectCase(Expression<C> expression);
+ <R> Case<R> selectCase();
+
+ public static interface Coalesce<T> extends Expression<T> {
+ //TODO: should we restrict the types to T?
+ Coalesce<T> value(Object value);
+ Coalesce<T> value(Expression<?> value);
+ }
+
+ <T> Coalesce<T> coalesce();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Root.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,10 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Entity;
+
+/**
+ * A root type in the from clause (always an entity type)
+ */
+public interface Root<X> extends From<X, X> {
+ Entity<X> getModel();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Selection.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+/**
+ * Defines an item that is returned by the query
+ */
+public interface Selection {
+ Class<?> getJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/SetJoin.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+package javax.jpa.criteria;
+
+import java.util.Set;
+
+public interface SetJoin<Z, E>
+ extends AbstractCollectionJoin<Z, Set<E>, E> {
+ javax.jpa.metamodel.Set<? super Z, E> getModel();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/criteria/Subquery.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,33 @@
+package javax.jpa.criteria;
+
+import javax.jpa.metamodel.Collection;
+import javax.jpa.metamodel.List;
+import javax.jpa.metamodel.Map;
+import javax.jpa.metamodel.Set;
+
+/**
+ * A top-level query has an expression as its selection
+ */
+public interface Subquery<T> extends AbstractQuery, Expression<T> {
+ AbstractQuery getParent();
+
+ Subquery<T> select(Expression<T> expression);
+
+ //override the return type only:
+ Subquery<T> where(Expression<Boolean> restriction);
+ Subquery<T> where(Predicate... restrictions);
+ Subquery<T> group(Expression<?>... grouping);
+ Subquery<T> having(Expression<Boolean> restriction);
+ Subquery<T> order(Order... o);
+ Subquery<T> distinct(boolean distinct);
+
+ Expression<T> getSelection();
+
+ <Y> Root<Y> correlate(Root<Y> parentRoot);
+ <X, Y> Join<X, Y> correlate(Join<X, Y> parentJoin);
+ <X, Y> CollectionJoin<X, Y> correlate(Collection<X, Y> parentCollection);
+ <X, Y> SetJoin<X, Y> correlate(Set<X, Y> parentSet);
+ <X, Y> ListJoin<X, Y> correlate(List<X, Y> parentList);
+ <X, K, V> MapJoin<X, K, V> correlate(Map<X, K, V> parentMap);
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/AbstractCollection.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,20 @@
+package javax.jpa.metamodel;
+
+/**
+ * A persistent collection
+ */
+public interface AbstractCollection<X, C, E>
+ extends Member<X, C>, Bindable<E> {
+
+ public static enum CollectionType {
+ collection, set, list, map
+ }
+
+ public static enum Multiplicity {
+ manyToMany, oneToMany, elements
+ }
+
+ CollectionType getCollectionType();
+ Multiplicity getMultiplicity();
+ Type<E> getElementType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Attribute.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents a persistent property or field that is not
+ * a collection.
+ * Note that the use of generics allows us to specify both
+ * the type of the attribute, and the type it belongs to.
+ */
+public interface Attribute<X, T>
+ extends Member<X, T>, Bindable<T> {
+
+ public static enum Multiplicity {
+ manyToOne, oneToOne, embedded, basic
+ }
+
+ Multiplicity getMultiplicity();
+ boolean isId();
+ boolean isVersion();
+ boolean isOptional();
+ Type<T> getAttributeType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Basic.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,6 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents a basic type (including temporal and enumerated types)
+ */
+public interface Basic<X> extends Type<X> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Bindable.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * Any kind of thing that can be bound into the from clause
+ */
+public interface Bindable<T> {
+
+ public static enum BindableType {
+ attribute, collection, managedType
+ }
+
+ BindableType getBindableType();
+
+ Class<T> getJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Collection.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,9 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents a persistent collection.
+ * Note that the use of generics allows us to specify both
+ * the type of the collection, and the type it belongs to.
+ */
+public interface Collection<X, E>
+ extends AbstractCollection<X, java.util.Collection<E>, E> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Embeddable.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface Embeddable<X>
+ extends ManagedType<X> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Entity.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,9 @@
+package javax.jpa.metamodel;
+
+/**
+ * An entity type
+ */
+public interface Entity<X> extends IdentifiableType<X> {
+ String getName();
+ Class<?> getIdJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/IdentifiableType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * Represents an entity or mapped superclass
+ */
+public interface IdentifiableType<X> extends ManagedType<X> {
+
+ <Y> Attribute<? super X, Y> getId(Class<Y> type);
+ <Y> Attribute<? super X, Y> getVersion(Class<Y> type);
+ <Y> Attribute<X, Y> getDeclaredId(Class<Y> type);
+ <Y> Attribute<X, Y> getDeclaredVersion(Class<Y> type);
+
+ IdentifiableType<? super X> getSupertype();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/List.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface List<X, E>
+ extends AbstractCollection<X, java.util.List<E>, E> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/ManagedType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,26 @@
+package javax.jpa.metamodel;
+
+/**
+ * An entity, mapped superclass or embeddable type
+ */
+public interface ManagedType<X> extends Type<X>, Bindable<X> {
+
+ <Y> Attribute<? super X, Y> getAttribute(String name, Class<Y> type);
+ <Y> Attribute<X, Y> getDeclaredAttribute(String name, Class<Y> type);
+
+ java.util.Set<Attribute<? super X, ?>> getAttributes();
+ java.util.Set<Attribute<X, ?>> getDeclaredAttributes();
+
+ <E> Collection<? super X, E> getCollection(String name, Class<E> elementType);
+ <E> Set<? super X, E> getSet(String name, Class<E> elementType);
+ <E> List<? super X, E> getList(String name, Class<E> elementType);
+ <K, V> Map<? super X, K, V> getMap(String name, Class<K> keyType, Class<V> valueType);
+ <E> Collection<X, E> getDeclaredColl(String name, Class<E> elementType);
+ <E> Set<X, E> getDeclaredSet(String name, Class<E> elementType);
+ <E> List<X, E> getDeclaredList(String name, Class<E> elementType);
+ <K, V> Map<X, K, V> getDeclaredMap(String name, Class<K> keyType, Class<V> valueType);
+
+ java.util.Set<AbstractCollection<? super X, ?, ?>> getCollections();
+ java.util.Set<AbstractCollection<X, ?, ?>> getDeclaredCollections();
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Map.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,7 @@
+package javax.jpa.metamodel;
+
+public interface Map<X, K, V>
+ extends AbstractCollection<X, java.util.Map<K, V>, V> {
+ Class<K> getKeyJavaType();
+ Type<K> getKeyType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/MappedSuperclass.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface MappedSuperclass<X>
+ extends IdentifiableType<X> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Member.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * A member of a Java type
+ */
+public interface Member<X, Y> {
+ //String getName(); //TODO: do we need this? the java.lang.reflect.Member has it
+ ManagedType<X> getDeclaringType();
+ Class<Y> getMemberJavaType();
+ java.lang.reflect.Member getJavaMember();
+ boolean isAssociation();
+ boolean isCollection();
+
+ //TODO: fetch type
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Metamodel.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+package javax.jpa.metamodel;
+
+/**
+ * Provides access to the metamodel of persistent
+ * entities in the persistence unit. It is better to
+ * access metamodel objects at initialization time
+ * and cache them statically to allow upfront type
+ * validation. However, they may also be accessed at
+ * runtime.
+ */
+public interface Metamodel {
+ <X> Entity<X> entity(Class<X> clazz);
+ <X> ManagedType<X> type(Class<X> clazz);
+ <X> Embeddable<X> embeddable(Class<X> clazz);
+ java.util.Set<ManagedType<?>> getManagedTypes();
+ java.util.Set<Entity<?>> getEntities();
+ java.util.Set<Embeddable<?>> getEmbeddables();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Set.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,4 @@
+package javax.jpa.metamodel;
+
+public interface Set<X, E>
+ extends AbstractCollection<X, java.util.Set<E>, E> {}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/Type.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,15 @@
+package javax.jpa.metamodel;
+
+/**
+ * Any type allowed for a persistent attribute
+ */
+public interface Type<X> {
+
+ public static enum PersistenceType {
+ entity, embeddable, mappedSuperclass, basic
+ }
+
+ PersistenceType getPersistenceType();
+
+ Class<X> getJavaType();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/jpa/metamodel/TypesafeMetamodel.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,10 @@
+package javax.jpa.metamodel;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface TypesafeMetamodel {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverride.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,34 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * This annotation is used to override a many-to-one or one-to-one mapping of property or field for
+ * an entity relationship.
+ * The AssociationOverride annotation may be applied to an entity that extends a mapped superclass
+ * to override a many-to-one or one-to-one mapping defined by the mapped superclass. If the
+ * AssociationOverride annotation is not specified, the join column is mapped the same as in
+ * the original mapping.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AssociationOverride {
+ /**
+ * The name of the relationship property whose mapping is being overridden if property-based
+ * access is being used, or the name of the relationship field if field-based access is used.
+ */
+ String name();
+
+ /**
+ * The join column that is being mapped to the persistent attribute.
+ */
+ JoinColumn[] joinColumns();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AssociationOverrides.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,24 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * This annotation is used to override mappings of multiple many-to-one
+ * or one-to-one relationship properties or fields.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AssociationOverrides {
+ /**
+ * Mapping overrides of relationship properties or fields
+ */
+ AssociationOverride[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverride.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,34 @@
+//$Id: AttributeOverride.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+
+/**
+ * The AttributeOverride annotation is used to override the mapping of a Basic (whether explicit
+ * or default) property or field or Id property or field.
+ *
+ * The AttributeOverride annotation may be applied to an entity that extends a mapped superclass
+ * or to an embedded field or property to override a basic mapping defined by the mapped superclass
+ * or embeddable class. If the AttributeOverride annotation is not specified, the column is mapped
+ * the same as in the original mapping.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AttributeOverride {
+ /**
+ * The name of the property whose mapping is being overridden if property-based access is being
+ * used, or the name of the field if field-based access is used.
+ */
+ String name();
+ /**
+ * The column that is being mapped to the persistent attribute
+ */
+ Column column();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/AttributeOverrides.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+//$Id: AttributeOverrides.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+
+/**
+ * Is used to override mappings of multiple properties or fields
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface AttributeOverrides {
+ /**
+ * One or more mapping override
+ */
+ AttributeOverride[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Basic.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,39 @@
+//$Id: Basic.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import static javax.persistence.FetchType.EAGER;
+
+/**
+ * The Basic annotation is the simplest type of mapping to a database column. The Basic
+ * annotation can be applied to a persistent property or instance variable of any of the
+ * following types: Java primitive types, wrappers of the primitive types, String,
+ * java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar,
+ * java.sql.Date, java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], Character[],
+ * enums, and any other type that implements Serializable.
+ *
+ * The use of the Basic annotation is optional for persistent fields and properties of these types.
+
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Basic {
+ /**
+ * Defines whether the value of the field or property should be lazily loaded or must be
+ * eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime
+ * that the value must be eagerly fetched. The LAZY strategy is a hint to the persistence
+ * provider runtime. If not specified, defaults to EAGER.
+ */
+ FetchType fetch() default EAGER;
+ /**
+ * Defines whether the value of the field or property may be null. This is a hint and is
+ * disregarded for primitive types; it may be used in schema generation. If not specified,
+ * defaults to true.
+ */
+ boolean optional() default true;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/CascadeType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,32 @@
+//$Id: CascadeType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines the set of cascadable operations that are propagated to the associated entity.
+ * The value cascade=ALL is equivalent to cascade={PERSIST, MERGE, REMOVE, REFRESH}.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum CascadeType {
+ /**
+ * Cascade all operations
+ */
+ ALL,
+ /**
+ * Cascade persist operations
+ */
+ PERSIST,
+ /**
+ * Cascade merge operations
+ */
+ MERGE,
+ /**
+ * Cascade remove operations
+ */
+ REMOVE,
+ /**
+ * Cascade refresh operations
+ */
+ REFRESH
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Column.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,65 @@
+//$Id: Column.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Is used to specify a mapped column for a persistent property or field. If no Column annotation is
+ * specified, the default values are applied.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Column {
+ /**
+ * The name of the column. Defaults to the property or field name
+ */
+ String name() default "";
+ /**
+ * Whether the property is a unique key. This is a shortcut for the UniqueConstraint
+ * annotation at the table level and is useful for when the unique key constraint is
+ * only a single field. This constraint applies in addition to any constraint entailed
+ * by primary key mapping and to constraints specified at the table level.
+ */
+ boolean unique() default false;
+ /**
+ * Whether the database column is nullable
+ */
+ boolean nullable() default true;
+ /**
+ * Whether the column is included in SQL INSERT statements generated by the persistence provider.
+ */
+ boolean insertable() default true;
+ /**
+ * Whether the column is included in SQL UPDATE statements generated by the persistence provider.
+ */
+ boolean updatable() default true;
+ /**
+ * The SQL fragment that is used when generating the DDL for the column.
+ * Defaults to the generated SQL to create a column of the inferred type.
+ */
+ String columnDefinition() default "";
+ /**
+ * The name of the table that contains the column. If absent the column is assumed to
+ * be in the primary table.
+ */
+ String table() default "";
+ /**
+ * The column length. (Applies only if a string-valued column is used.)
+ */
+ int length() default 255;
+ /**
+ * The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+ * Value must be set by developer if used when generating the DDL for the column.
+ */
+ int precision() default 0;
+ /**
+ * The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+ */
+ int scale() default 0;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ColumnResult.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,22 @@
+//$Id: ColumnResult.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * References name of a column in the SELECT clause of a SQL query - i.e.,
+ * column alias, if applicable. Scalar result types can be included in the query
+ * result by specifying this annotation in the metadata.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RetentionPolicy.RUNTIME)
+public @interface ColumnResult {
+ /**
+ * The name of a column in the SELECT clause of a SQL query
+ */
+ String name();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorColumn.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,47 @@
+//$Id: DiscriminatorColumn.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.DiscriminatorType.STRING;
+
+/**
+ * Is used to define the discriminator column for the SINGLE_TABLE and JOINED inheritance
+ * mapping strategies.
+ *
+ * The strategy and the discriminator column are only specified in the root of an entity
+ * class hierarchy or subhierarchy in which a different inheritance strategy is applied
+ *
+ * If the DiscriminatorColumn annotation is missing, and a discriminator column is required,
+ * the name of the discriminator column defaults to "DTYPE" and the discriminator type to
+ * DiscriminatorType.STRING.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface DiscriminatorColumn {
+ /**
+ * The name of column to be used for the discriminator.
+ */
+ String name() default "DTYPE";
+ /**
+ * The type of object/column to use as a class discriminator.
+ * Defaults to DiscriminatorType.STRING
+ */
+ DiscriminatorType discriminatorType() default STRING;
+ /**
+ * The SQL fragment that is used when generating the DDL for the discriminator column.
+ * Defaults to the provider-generated SQL to create a column of the specified
+ * discriminator type.
+ */
+ String columnDefinition() default "";
+ /**
+ * The column length for String-based discriminator types. Ignored for other
+ * discriminator types.
+ */
+ int length() default 31;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+//$Id: DiscriminatorType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines supported types of the discriminator column
+ *
+ * @author Emmanuel Bernard
+ */
+public enum DiscriminatorType {
+ /**
+ * String as the discriminator type
+ */
+ STRING,
+ /**
+ * Single character as the discriminator type
+ */
+ CHAR,
+ /**
+ * Integer as the discriminator type
+ */
+ INTEGER
+};
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/DiscriminatorValue.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,33 @@
+//$Id: DiscriminatorValue.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+
+/**
+ * Is used to specify the value of the discriminator column for entities of the given type.
+ * The DiscriminatorValue annotation can only be specified on a concrete entity class.
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ *
+ * The inheritance strategy and the discriminator column are only specified in the root
+ * of an entity class hierarchy or subhierarchy in which a different inheritance strategy
+ * is applied. The discriminator value, if not defaulted, should be specified for each entity
+ * class in the hierarchy.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface DiscriminatorValue {
+ /**
+ * The value that indicates that the row is an entity of the annotated entity type.
+ *
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ */
+ String value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Embeddable.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,22 @@
+//$Id: Embeddable.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB Specification Copyright 2004 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+
+/**
+ * Defines a class whose instances are stored as an intrinsic part of an owning entity and share
+ * the identity of the entity. Each of the persistent properties or fields of the embedded object
+ * is mapped to the database table for the entity. Only Basic, Column, Lob, Temporal, and
+ * Enumerated mapping annotations may portably be used to map the persistent fields or properties
+ * of classes annotated as Embeddable.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface Embeddable {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Embedded.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+//$Id: Embedded.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB Specification Copyright 2004 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Defines a persistent field or property of an entity whose value is an instance of
+ * an embeddable class. The embeddable class must be annotated as Embeddable.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Embedded {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EmbeddedId.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,19 @@
+//$Id: EmbeddedId.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Is applied to a persistent field or property of an entity class or mapped superclass to denote
+ * a composite primary key that is an embeddable class. The embeddable class must be annotated
+ * as Embeddable.
+ *
+ * @author Emmanuel Bernard
+ */
+(a)Target({ElementType.METHOD, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface EmbeddedId {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Entity.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+//$Id: Entity.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Specifies that the class is an entity. This annotation is applied to the entity class.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface Entity {
+ /**
+ * The name of an entity. Defaults to the unqualified name of the entity class.
+ * This name is used to refer to the entity in queries. The name must not be a
+ * reserved literal in the Java Persistence query language.
+ */
+ String name() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityExistsException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,45 @@
+//$Id: $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when EntityManager.persist(Object) is called and the
+ * entity already exists. The current transaction, if one is active, will be marked for rollback.
+ *
+ * @author Emmanuel Bernard
+ */
+public class EntityExistsException extends PersistenceException {
+ /**
+ * Constructs a new EntityExistsException exception with null as its detail message.
+ */
+ public EntityExistsException() {
+ super();
+ }
+
+ /**
+ * Constructs a new EntityExistsException exception with the specified cause.
+ *
+ * @param cause the cause
+ */
+ public EntityExistsException(Throwable cause) {
+ super( cause );
+ }
+
+ /**
+ * Constructs a new EntityExistsException exception with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public EntityExistsException(String message) {
+ super( message );
+ }
+
+ /**
+ * Constructs a new EntityExistsException exception with the specified detail message and cause.
+ *
+ * @param message the detail message.
+ * @param cause the cause.
+ */
+ public EntityExistsException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityListeners.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Specifies the callback listener classes to be used for an entity or mapped superclass.
+ * This annotation may be applied to an entity class or mapped superclass.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface EntityListeners {
+ /**
+ * The callback listener classes
+ */
+ Class[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManager.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,298 @@
+// $Id: EntityManager.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Interface used to interact with the persistence context.
+ *
+ * An EntityManager instance is associated with a persistence context. A persistence context is a set of
+ * entity instances in which for any persistent entity identity there is a unique entity instance.
+ * Within the persistence context, the entity instances and their lifecycle are managed. This interface
+ * defines the methods that are used to interact with the persistence context. The EntityManager API is
+ * used to create and remove persistent entity instances, to find entities by their primary key, and to
+ * query over entities.
+ *
+ * The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit.
+ * A persistence unit defines the set of all classes that are related or grouped by the application, and
+ * which must be colocated in their mapping to a single database.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface EntityManager {
+ /**
+ * Make an entity instance managed and persistent.
+ *
+ * @param entity
+ * @throws EntityExistsException if the entity already exists.
+ * (The EntityExistsException may be thrown when the persist
+ * operation is invoked, or the EntityExistsException or
+ * another PersistenceException may be thrown at commit
+ * time.)
+ * @throws IllegalStateException if this EntityManager has been closed.
+ * @throws IllegalArgumentException if not an entity
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ */
+ public void persist(Object entity);
+
+ /**
+ * Merge the state of the given entity into the
+ * current persistence context.
+ *
+ * @param entity
+ * @return the instance that the state was merged to
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if instance is not an
+ * entity or is a removed entity
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ */
+ public <T> T merge(T entity);
+
+ /**
+ * Remove the entity instance.
+ *
+ * @param entity
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if not an entity
+ * or if a detached entity
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ */
+ public void remove(Object entity);
+
+ /**
+ * Find by primary key.
+ *
+ * @param entityClass
+ * @param primaryKey
+ * @return the found entity instance or null
+ * if the entity does not exist
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if the first argument does
+ * not denote an entity type or the second
+ * argument is not a valid type for that
+ * entity’s primary key
+ */
+ public <T> T find(Class<T> entityClass, Object primaryKey);
+
+ /**
+ * Get an instance, whose state may be lazily fetched.
+ * If the requested instance does not exist in the database,
+ * the EntityNotFoundException is thrown when the instance
+ * state is first accessed. (The persistence provider runtime is
+ * permitted to throw the EntityNotFoundException when
+ * getReference is called.)
+ * The application should not expect that the instance state will
+ * be available upon detachment, unless it was accessed by the
+ * application while the entity manager was open.
+ *
+ * @param entityClass
+ * @param primaryKey
+ * @return the found entity instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if the first argument does
+ * not denote an entity type or the second
+ * argument is not a valid type for that
+ * entity’s primary key
+ * @throws EntityNotFoundException if the entity state
+ * cannot be accessed
+ */
+ public <T> T getReference(Class<T> entityClass, Object primaryKey);
+
+ /**
+ * Synchronize the persistence context to the
+ * underlying database.
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws TransactionRequiredException if there is
+ * no transaction
+ * @throws PersistenceException if the flush fails
+ */
+ public void flush();
+
+ /**
+ * Set the flush mode that applies to all objects contained
+ * in the persistence context.
+ *
+ * @param flushMode
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public void setFlushMode(FlushModeType flushMode);
+
+ /**
+ * Get the flush mode that applies to all objects contained
+ * in the persistence context.
+ *
+ * @return flushMode
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public FlushModeType getFlushMode();
+
+ /**
+ * Set the lock mode for an entity object contained
+ * in the persistence context.
+ *
+ * @param entity
+ * @param lockMode
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws PersistenceException if an unsupported lock call
+ * is made
+ * @throws IllegalArgumentException if the instance is not
+ * an entity or is a detached entity
+ * @throws TransactionRequiredException if there is no
+ * transaction
+ */
+ public void lock(Object entity, LockModeType lockMode);
+
+ /**
+ * Refresh the state of the instance from the database,
+ * overwriting changes made to the entity, if any.
+ *
+ * @param entity
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if not an entity
+ * or entity is not managed
+ * @throws TransactionRequiredException if invoked on a
+ * container-managed entity manager of type
+ * PersistenceContextType.TRANSACTION and there is
+ * no transaction.
+ * @throws EntityNotFoundException if the entity no longer
+ * exists in the database
+ */
+ public void refresh(Object entity);
+
+ /**
+ * Clear the persistence context, causing all managed
+ * entities to become detached. Changes made to entities that
+ * have not been flushed to the database will not be
+ * persisted.
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public void clear();
+
+ /**
+ * Check if the instance belongs to the current persistence
+ * context.
+ *
+ * @param entity
+ * @return <code>true</code> if the instance belongs to the current persistence context.
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if not an entity
+ */
+ public boolean contains(Object entity);
+
+ /**
+ * Create an instance of Query for executing an
+ * EJB QL statement.
+ *
+ * @param ejbqlString an EJB QL query string
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if query string is not valid
+ */
+ public Query createQuery(String ejbqlString);
+
+ /**
+ * Create an instance of Query for executing a
+ * named query (in EJB QL or native SQL).
+ *
+ * @param name the name of a query defined in metadata
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws IllegalArgumentException if a query has not been
+ * defined with the given name
+ */
+ public Query createNamedQuery(String name);
+
+ /**
+ * Create an instance of Query for executing
+ * a native SQL statement, e.g., for update or delete.
+ *
+ * @param sqlString a native SQL query string
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Query createNativeQuery(String sqlString);
+
+ /**
+ * Create an instance of Query for executing
+ * a native SQL query.
+ *
+ * @param sqlString a native SQL query string
+ * @param resultClass the class of the resulting instance(s)
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Query createNativeQuery(String sqlString, Class resultClass);
+
+ /**
+ * Create an instance of Query for executing
+ * a native SQL query.
+ *
+ * @param sqlString a native SQL query string
+ * @param resultSetMapping the name of the result set mapping
+ * @return the new query instance
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Query createNativeQuery(String sqlString, String resultSetMapping);
+
+ /**
+ * Indicate to the EntityManager that a JTA transaction is
+ * active. This method should be called on a JTA application
+ * managed EntityManager that was created outside the scope
+ * of the active transaction to associate it with the current
+ * JTA transaction.
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ * @throws TransactionRequiredException if there is
+ * no transaction.
+ */
+ public void joinTransaction();
+
+ /**
+ * Return the underlying provider object for the EntityManager, if available.
+ * The result of this method is implementation specific
+ *
+ * @throws IllegalStateException if this EntityManager has been closed
+ */
+ public Object getDelegate();
+
+ /**
+ * Close an application-managed EntityManager.
+ * After the close method has been invoked, all methods
+ * on the EntityManager instance and any Query objects obtained
+ * from it will throw the IllegalStateException except
+ * for getTransaction and isOpen (which will return false).
+ * If this method is called when the EntityManager is
+ * associated with an active transaction, the persistence
+ * context remains managed until the transaction completes.
+ *
+ * @throws IllegalStateException if the EntityManager is container-managed or has been already closed
+ */
+ public void close();
+
+ /**
+ * Determine whether the EntityManager is open.
+ *
+ * @return true until the EntityManager has been closed.
+ */
+ public boolean isOpen();
+
+ /**
+ * Return the resource-level transaction object.
+ * The EntityTransaction instance may be used serially to
+ * begin and commit multiple transactions.
+ *
+ * @return EntityTransaction instance
+ * @throws IllegalStateException if invoked on a JTA
+ * EntityManager.
+ */
+ public EntityTransaction getTransaction();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityManagerFactory.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,49 @@
+//$Id: EntityManagerFactory.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.util.Map;
+
+/**
+ * The EntityManagerFactory interface is used by the application to obtain an
+ * application-managed entity manager. When the application has finished using
+ * the entity manager factory, and/or at application shutdown, the application
+ * should close the entity manager factory. Once an EntityManagerFactory has been
+ * closed, all its entity managers are considered to be in the closed state.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface EntityManagerFactory {
+
+ /**
+ * Create a new EntityManager.
+ * This method returns a new EntityManager instance each time
+ * it is invoked.
+ * The isOpen method will return true on the returned instance.
+ */
+ EntityManager createEntityManager();
+
+ /**
+ * Create a new EntityManager with the specified Map of
+ * properties.
+ * This method returns a new EntityManager instance each time
+ * it is invoked.
+ * The isOpen method will return true on the returned instance.
+ */
+ EntityManager createEntityManager(Map map);
+
+ /**
+ * Close the factory, releasing any resources that it holds.
+ * After a factory instance is closed, all methods invoked on
+ * it will throw an IllegalStateException, except for isOpen,
+ * which will return false. Once an EntityManagerFactory has
+ * been closed, all its entity managers are considered to be
+ * in the closed state.
+ */
+ void close();
+
+ /**
+ * Indicates whether or not this factory is open. Returns
+ * true until a call to close has been made.
+ */
+ public boolean isOpen();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityNotFoundException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,29 @@
+//$Id: EntityNotFoundException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when an entity reference obtained by
+ * EntityManager.getReference(Class,Object) is accessed but the entity does not exist.
+ * Also thrown when EntityManager.refresh(Object) is called and the object no longer exists
+ * in the database. The current transaction, if one is active, will be marked for rollback.
+ *
+ * @author Gavin King
+ */
+public class EntityNotFoundException extends PersistenceException {
+ /**
+ * Constructs a new EntityNotFoundException exception with null as its detail message.
+ */
+ public EntityNotFoundException() {
+ super();
+ }
+
+ /**
+ * Constructs a new EntityNotFoundException exception with the specified detail message.
+ *
+ * @param message the detail message
+ */
+ public EntityNotFoundException(String message) {
+ super( message );
+ }
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityResult.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,33 @@
+//$Id: EntityResult.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * References an entity in the SELECT clause of a SQL query. If this annotation is used,
+ * the SQL statement should select all of the columns that are mapped to the entity object.
+ * This should include foreign key columns to related entities. The results obtained when
+ * insufficient data is available are undefined.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RetentionPolicy.RUNTIME)
+public @interface EntityResult {
+ /**
+ * The class of the result
+ */
+ Class entityClass();
+ /**
+ * Maps the columns specified in the SELECT list of the query to the properties or
+ * fields of the entity class.
+ */
+ FieldResult[] fields() default {};
+ /**
+ * Specifies the column name (or alias) of the column in the SELECT list that is used to
+ * determine the type of the entity instance.
+ */
+ String discriminatorColumn() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EntityTransaction.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,60 @@
+//$Id: EntityTransaction.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * The EntityTransaction interface is used to control resource transactions
+ * on resource-local entity managers. The EntityManager.getTransaction()
+ * method returns the EntityTransaction interface.
+ *
+ * @author Emmanuel Bernard
+ */
+public interface EntityTransaction {
+ /**
+ * Start a resource transaction.
+ *
+ * @throws IllegalStateException if isActive() is true.
+ */
+ public void begin();
+
+ /**
+ * Commit the current transaction, writing any unflushed
+ * changes to the database.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ * @throws RollbackException if the commit fails.
+ */
+ public void commit();
+
+ /**
+ * Roll back the current transaction.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ * @throws PersistenceException if an unexpected error
+ * condition is encountered.
+ */
+ public void rollback();
+
+ /**
+ * Mark the current transaction so that the only possible
+ * outcome of the transaction is for the transaction to be
+ * rolled back.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ */
+ public void setRollbackOnly();
+
+ /**
+ * Determine whether the current transaction has been marked
+ * for rollback.
+ *
+ * @throws IllegalStateException if isActive() is false.
+ */
+ public boolean getRollbackOnly();
+
+ /**
+ * Indicate whether a transaction is in progress.
+ * @throws PersistenceException if an unexpected error
+ * condition is encountered.
+ */
+ public boolean isActive();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/EnumType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,19 @@
+//$Id: EnumType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Defines mapping for the enumerated types. The constants of this enumerated type specify how persistent
+ * property or field should be persisted as a enumerated type.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum EnumType {
+ /**
+ * Persist enumerated type property or field as an integer
+ */
+ ORDINAL,
+ /**
+ * Persist enumerated type property or field as a string
+ */
+ STRING
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Enumerated.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,24 @@
+//$Id: Enumerated.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+import static javax.persistence.EnumType.*;
+
+/**
+ * Specifies that a persistent property or field should be persisted as a enumerated type.
+ * It may be used in conjunction with the Basic annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Enumerated {
+ /**
+ * The type used in mapping an enum type
+ */
+ EnumType value() default ORDINAL;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeDefaultListeners.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,17 @@
+//$Id: ExcludeDefaultListeners.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Specifies that the invocation of default listeners is to be excluded for the entity class
+ * (or mapped superclass) and its subclasses.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface ExcludeDefaultListeners {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ExcludeSuperclassListeners.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,17 @@
+//$Id: ExcludeSuperclassListeners.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+
+/**
+ * Specifies that the invocation of superclass listeners is to be excluded for the
+ * entity class (or mapped superclass) and its subclasses.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface ExcludeSuperclassListeners {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/FetchType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,24 @@
+//$Id: FetchType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines strategies for fetching data from the database.
+ * The EAGER strategy is a requirement on the persistence provider runtime that data must
+ * be eagerly fetched. The LAZY strategy is a hint to the persistence provider runtime that
+ * data should be fetched lazily when it is first accessed. The implementation is permitted to
+ * eagerly fetch data for which the LAZY strategy hint has been specified. In particular, lazy
+ * fetching might only be available for Basic mappings for which property-based access is used.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum FetchType {
+ /**
+ * Defines that data must be lazily fetched
+ */
+ LAZY,
+ /**
+ * Defines that data must be eagerly fetched
+ */
+ EAGER
+};
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/FieldResult.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+//$Id: FieldResult.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Is used to map the columns specified in the SELECT list of the query to the properties
+ * or fields of the entity class.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RetentionPolicy.RUNTIME)
+public @interface FieldResult {
+ /**
+ * Name of the persistent field or property of the class.
+ */
+ String name();
+ /**
+ * Name of the column in the SELECT clause - i.e., column aliases, if applicable.
+ */
+ String column();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/FlushModeType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,29 @@
+//$Id: FlushModeType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Flush mode setting.
+ *
+ * When queries are executed within a transaction, if FlushModeType.AUTO is set on the Query object,
+ * or if the flush mode setting for the persistence context is AUTO (the default) and a flush mode
+ * setting has not been specified for the Query object, the persistence provider is responsible for
+ * ensuring that all updates to the state of all entities in the persistence context which could
+ * potentially affect the result of the query are visible to the processing of the query.
+ * The persistence provider implementation may achieve this by flushing those entities to the database
+ * or by some other means. If FlushModeType.COMMIT is set, the effect of updates made to entities in the
+ * persistence context upon queries is unspecified.
+ *
+ * If there is no transaction active, the persistence provider must not flush to the database.
+ *
+ * @author Gavin King
+ */
+public enum FlushModeType {
+ /**
+ * Flushing must occur only at transaction commit
+ */
+ COMMIT,
+ /**
+ * (Default) Flushing to occur at query execution
+ */
+ AUTO
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/GeneratedValue.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,32 @@
+//$Id: GeneratedValue.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Provides for the specification of generation strategies for the values of primary keys.
+ * The GeneratedValue annotation may be applied to a primary key property or field of an entity
+ * or mapped superclass in conjunction with the Id annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface GeneratedValue {
+ /**
+ * The primary key generation strategy that the persistence provider must use
+ * to generate the annotated entity primary key.
+ */
+ GenerationType strategy() default GenerationType.AUTO;
+ /**
+ * The name of the primary key generator to use as specified in the SequenceGenerator or
+ * TableGenerator annotation.
+ *
+ * Defaults to the id generator supplied by persistence provider.
+ */
+ String generator() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/GenerationType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,34 @@
+//$Id: GenerationType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines the types of primary key generation.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum GenerationType {
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using an underlying
+ * database table to ensure uniqueness.
+ */
+ TABLE,
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using database
+ * sequence column.
+ */
+ SEQUENCE,
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using
+ * database identity column.
+ */
+ IDENTITY,
+ /**
+ * Indicates that the persistence provider should pick an appropriate strategy for the
+ * particular database. The AUTO generation strategy may expect a database resource
+ * to exist, or it may attempt to create one. A vendor may provide documentation on how
+ * to create such resources in the event that it does not support schema generation or cannot
+ * create the schema resource at runtime.
+ */
+ AUTO
+};
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Id.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+//$Id: Id.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+
+/**
+ * Specifies the primary key property or field of an entity.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Id {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/IdClass.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,26 @@
+//$Id: IdClass.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Specifies a composite primary key class that is mapped to multiple fields or properties
+ * of the entity.
+ *
+ * The names of the fields or properties in the primary key class and the primary key fields
+ * or properties of the entity must correspond and their types must be the same.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface IdClass {
+ /**
+ * Primary key class
+ */
+ Class value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Inheritance.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+//$Id: Inheritance.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import static javax.persistence.InheritanceType.SINGLE_TABLE;
+
+/**
+ * Defines the inheritance strategy to be used for an entity class hierarchy. It is specified
+ * on the entity class that is the root of the entity class hierarchy.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface Inheritance {
+ /**
+ * The strategy to be used
+ */
+ InheritanceType strategy() default SINGLE_TABLE;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/InheritanceType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+//$Id: InheritanceType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Defines inheritance strategy options.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum InheritanceType
+{
+ /**
+ * A single table per class hierarchy
+ */
+ SINGLE_TABLE,
+ /**
+ * A table per concrete entity class
+ */
+ TABLE_PER_CLASS,
+ /**
+ * A strategy in which fields that are specific to a subclass are mapped to a separate
+ * table than the fields that are common to the parent class, and a join is performed
+ * to instantiate the subclass.
+ */
+ JOINED };
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumn.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,67 @@
+//$Id: JoinColumn.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Is used to specify a mapped column for joining an entity association.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface JoinColumn {
+ /**
+ * The name of the foreign key column.
+ * The table in which it is found depends upon the context. If the join is for a OneToOne
+ * or Many- ToOne mapping, the foreign key column is in the table of the source entity.
+ * If the join is for a ManyToMany, the foreign key is in a join table. Default (only applies
+ * if a single join column is used): The concatenation of the following: the name of the referencing
+ * relationship property or field of the referencing entity; "_"; the name of the referenced primary
+ * key column. If there is no such referencing relationship property or field in the entity, the join
+ * column name is formed as the concatenation of the following: the name of the entity; "_"; the name
+ * of the referenced primary key column.
+ */
+ String name() default "";
+ /**
+ * The name of the column referenced by this foreign key column. When used with relationship mappings,
+ * the referenced column is in the table of the target entity. When used inside a JoinTable annotation,
+ * the referenced key column is in the entity table of the owning entity, or inverse entity if the join
+ * is part of the inverse join definition. Default (only applies if single join column is being used):
+ * The same name as the primary key column of the referenced table.
+ */
+ String referencedColumnName() default "";
+ /**
+ * Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the
+ * table level and is useful for when the unique key constraint is only a single field. It is not
+ * necessary to explicitly specify this for a join column that corresponds to a primary key that is part
+ * of a foreign key.
+ */
+ boolean unique() default false;
+ /**
+ * Whether the foreign key column is nullable
+ */
+ boolean nullable() default true;
+ /**
+ * Whether the column is included in SQL INSERT statements generated by the persistence provider
+ */
+ boolean insertable() default true;
+ /**
+ * Whether the column is included in SQL UPDATE statements generated by the persistence provider
+ */
+ boolean updatable() default true;
+ /**
+ * The SQL fragment that is used when generating the DDL for the column.
+ * Defaults to the generated SQL for the column.
+ */
+ String columnDefinition() default "";
+ /**
+ * The name of the table that contains the column. If a table is not specified, the column is
+ * assumed to be in the primary table of the applicable entity
+ */
+ String table() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinColumns.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+//$Id: JoinColumns.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Defines mapping for the composite foreign keys.
+ * This annotation groups JoinColumn annotations for the same relationship.
+ *
+ * When the JoinColumns annotation is used, both the name and the referencedColumnName
+ * elements must be specified in each such JoinColumn annotation.
+
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface JoinColumns {
+ JoinColumn[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/JoinTable.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,63 @@
+//$Id: JoinTable.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation is used in the mapping of associations. It is specified on the owning
+ * side of a many-to-many association, or in a unidirectional one-to-many association.
+ *
+ * If the JoinTable annotation is missing, the default values of the annotation elements apply.
+ * The name of the join table is assumed to be the table names of the associated primary tables
+ * concatenated together (owning side first) using an underscore.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface JoinTable {
+ /**
+ * The name of the join table.
+ *
+ * Defaults to the concatenated names of the two associated primary entity tables,
+ * separated by an underscore
+ */
+ String name() default "";
+ /**
+ * The catalog of the table.
+ *
+ * Defaults to the default catalog.
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table.
+ *
+ * Defaults to the default schema for user.
+ */
+ String schema() default "";
+ /**
+ * The foreign key columns of the join table which reference the primary table of the
+ * entity owning the association (i.e. the owning side of the association).
+ *
+ * Uses the same defaults as for JoinColumn.
+ */
+ JoinColumn[] joinColumns() default {};
+ /**
+ * The foreign key columns of the join table which reference the primary table of the entity
+ * that does not own the association (i.e. the inverse side of the association).
+ *
+ * Uses the same defaults as for JoinColumn
+ */
+ JoinColumn[] inverseJoinColumns() default {};
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table
+ * generation is in effect.
+ *
+ * Defaults to no additional constraints
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Lob.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+//$Id: Lob.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.METHOD;
+
+import static java.lang.annotation.ElementType.FIELD;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+
+/**
+ * Specifies that a persistent property or field should be persisted as a large object to a
+ * database-supported large object type. The Lob annotation may be used in conjunction with
+ * the Basic annotation. A Lob may be either a binary or character type.
+ *
+ * The Lob type is inferred from the type of the persistent field or property, and except
+ * for string and character-based types defaults to Blob.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Lob {}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/LockModeType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,40 @@
+//$Id: LockModeType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Lock modes that can be specified by means of the EntityManager.lock() method.
+ *
+ * The semantics of requesting locks of type LockModeType.READ and LockModeType.WRITE are t
+ * he following.
+ *
+ * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
+ * manager must ensure that neither of the following phenomena can occur:
+ *
+ * * P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads
+ * that row and obtains the modified value, before T1 has committed or rolled back.
+ * Transaction T2 eventually commits successfully; it does not matter whether T1 commits or rolls
+ * back and whether it does so before or after T2 commits.
+ *
+ * * P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies
+ * or deletes that row, before T1 has committed. Both transactions eventually commit successfully.
+ *
+ * Lock modes must always prevent the phenomena P1 and P2.
+ * In addition, calling lock(entity, LockModeType.WRITE) on a versioned object,
+ * will also force an update (increment) to the entity's version column.
+ *
+ * The persistence implementation is not required to support calling EntityManager.lock()
+ * on a non-versioned object. When it cannot support a such lock call, it must
+ * throw the PersistenceException.
+ *
+ * @author Emmanuel Bernard
+ */
+public enum LockModeType {
+ /**
+ * Read lock
+ */
+ READ,
+ /**
+ * Write lock
+ */
+ WRITE
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToMany.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,51 @@
+//$Id: ManyToMany.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * Defines a many-valued association with many-to-many multiplicity. If the Collection is
+ * defined using generics to specify the element type, the associated target entity class
+ * does not need to be specified; otherwise it must be specified.
+ *
+ * Every many-to-many association has two sides, the owning side and the non-owning, or inverse,
+ * side. The join table is specified on the owning side. If the association is bidirectional,
+ * either side may be designated as the owning side.
+ *
+ * The same annotation elements for the OneToMany annotation apply to the ManyToMany annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface ManyToMany {
+ /**
+ * The entity class that is the target of the association. Optional only if the
+ * collection property is defined using Java generics. Must be specified otherwise.
+ *
+ * Defaults to the parameterized type of the collection when defined using generics.
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * Defaults to no operations being cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistenceprovider runtime that
+ * the associatedentities must be eagerly fetched. The LAZY strategy is a hint
+ * to the persistence provider runtime.
+ */
+ FetchType fetch() default LAZY;
+ /**
+ * The field that owns the relationship. Required unless the relationship is unidirectional.
+ */
+ String mappedBy() default "";
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/ManyToOne.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,44 @@
+//$Id: ManyToOne.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * This annotation defines a single-valued association to another entity class that has
+ * many-to-one multiplicity. It is not normally necessary to specify the target entity
+ * explicitly since it can usually be inferred from the type of the object being referenced.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface ManyToOne {
+ /**
+ * The entity class that is the target of the association.
+ *
+ * Defaults to the type of the field or property that stores the association
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * By default no operations are cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistence provider runtime that
+ * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+ * the persistence provider runtime.
+ */
+ FetchType fetch() default EAGER;
+ /**
+ * Whether the association is optional. If set to false then a non-null relationship must always exist.
+ */
+ boolean optional() default true;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/MapKey.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+
+/**
+ * Is used to specify the map key for associations of type Map.
+ * If a persistent field or property other than the primary key is used as a map key then it
+ * is expected to have a uniqueness constraint associated with it.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface MapKey {
+ /**
+ * The name of the persistent field or property of the associated entity that is used as the map key.
+ * If the name element is not specified, the primary key of the associated entity is used as the map key.
+ * If the primary key is a composite primary key and is mapped as IdClass, an instance of the primary key
+ * class is used as the key.
+ */
+ String name() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/MappedSuperclass.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+//$Id: MappedSuperclass.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Designates a class whose mapping information is applied to the entities that inherit
+ * from it. A mapped superclass has no separate table defined for it.
+ *
+ * A class designated with the MappedSuperclass annotation can be mapped in the same way as
+ * an entity except that the mappings will apply only to its subclasses since no table exists
+ * for the mapped superclass itself. When applied to the subclasses the inherited mappings will
+ * apply in the context of the subclass tables. Mapping information may be overridden in such
+ * subclasses by using the AttributeOverride and AssociationOverride annotations or corresponding *
+ * XML elements.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target(TYPE) @Retention(RUNTIME)
+public @interface MappedSuperclass {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQueries.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+//$Id: NamedNativeQueries.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Is used to specify an array of native SQL named queries. Query names are scoped to the persistence unit
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface NamedNativeQueries {
+ /**
+ * Array of native SQL named queries
+ */
+ NamedNativeQuery [] value ();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedNativeQuery.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,39 @@
+//$Id: NamedNativeQuery.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.*;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Is used to specify a native SQL named query. Query names are scoped to the persistence unit.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE})
+@Retention(RUNTIME)
+public @interface NamedNativeQuery {
+ /**
+ * Is used to refer to the query when using the EntityManager methods that create query objects
+ */
+ String name();
+ /**
+ * The SQL query string
+ */
+ String query();
+
+ /**
+ * Vendor-specific query hints
+ */
+ QueryHint[] hints() default {};
+ /**
+ * The class of the result
+ */
+ Class resultClass() default void.class;
+ /**
+ * The name of a SqlResultSetMapping, as defined in metadata
+ */
+ String resultSetMapping() default ""; // name of SQLResultSetMapping
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQueries.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+//$Id: NamedQueries.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Specifies an array of named Java Persistence query language queries. Query names are scoped to the persistence unit.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface NamedQueries {
+ /**
+ * An array of named Java Persistence query language queries.
+ */
+ NamedQuery [] value ();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NamedQuery.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,31 @@
+//$Id: NamedQuery.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+/**
+ * Is used to specify a named query in the Java Persistence query language, which is a static
+ * query expressed in metadata. Query names are scoped to the persistence unit.
+ *
+ * @author Emmanuel Bernard
+ */
+//TODO remove the mackage target
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface NamedQuery {
+ /**
+ * Refers to the query when using the EntityManager methods that create query objects.
+ */
+ String name();
+ /**
+ * The query string in the Java Persistence query language
+ */
+ String query();
+ /**
+ * Vendor-specific query hints
+ */
+ QueryHint[] hints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NoResultException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,27 @@
+//$Id: NoResultException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when getSingleResult() is executed on a query and there is no result to return.
+ * This exception will not cause the current transaction, if one is active, to be marked for roll back.
+ *
+ * @author Emmanuel Bernard
+ */
+public class NoResultException extends PersistenceException {
+
+ /**
+ * Constructs a new NoResultException exception with null as its detail message
+ */
+ public NoResultException() {
+ super();
+ }
+
+ /**
+ * Constructs a new NoResultException exception with the specified detail message.
+ *
+ * @param message
+ */
+ public NoResultException(String message) {
+ super( message );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/NonUniqueResultException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,29 @@
+//$Id: NonUniqueResultException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when getSingleResult() is executed on a query and there is more than
+ * one result from the query. This exception will not cause the current transaction, if one is active, to be
+ * marked for roll back.
+ *
+ * @author Gavin King
+ */
+public class NonUniqueResultException extends PersistenceException {
+
+ /**
+ * Constructs a new NonUniqueResultException exception with null as its detail message
+ */
+ public NonUniqueResultException() {
+ super();
+ }
+
+ /**
+ * Constructs a new NonUniqueResultException exception with the specified detail message
+ *
+ * @param message
+ */
+ public NonUniqueResultException(String message) {
+ super( message );
+ }
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToMany.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,47 @@
+//$Id: OneToMany.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * Defines a many-valued association with one-to-many multiplicity.
+ *
+ * If the collection is defined using generics to specify the element type,
+ * the associated target entity type need not be specified; otherwise the target
+ * entity class must be specified.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface OneToMany {
+ /**
+ * The entity class that is the target of the association. Optional only if the collection
+ * property is defined using Java generics. Must be specified otherwise.
+ *
+ * Defaults to the parameterized type of the collection when defined using generics.
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * Defaults to no operations being cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistenceprovider runtime that the
+ * associatedentities must be eagerly fetched. The LAZY strategy is a hint to the
+ * persistence provider runtime.
+ */
+ FetchType fetch() default LAZY;
+ /**
+ * The field that owns the relationship. Required unless the relationship is unidirectional.
+ */
+ String mappedBy() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OneToOne.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,51 @@
+//$Id: OneToOne.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static javax.persistence.FetchType.*;
+
+/**
+ * This annotation defines a single-valued association to another entity that has
+ * one-to-one multiplicity. It is not normally necessary to specify the associated
+ * target entity explicitly since it can usually be inferred from the type of the object
+ * being referenced.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface OneToOne {
+ /**
+ * The entity class that is the target of the association.
+ *
+ * Defaults to the type of the field or property that stores the association.
+ */
+ Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * By default no operations are cascaded.
+ */
+ CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistence provider runtime that
+ * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+ * the persistence provider runtime.
+ */
+ FetchType fetch() default EAGER;
+ /**
+ * Whether the association is optional. If set to false then a non-null relationship must
+ * always exist.
+ */
+ boolean optional() default true;
+ /**
+ * The field that owns the relationship. This element is only specified on the
+ * inverse (non-owning) side of the association.
+ */
+ String mappedBy() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OptimisticLockException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,42 @@
+//$Id: $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when an optimistic locking conflict occurs.
+ * This exception may be thrown as part of an API call, a flush or at commit time.
+ * The current transaction, if one is active, will be marked for rollback.
+ *
+ * @author Emmanuel Bernard
+ */
+public class OptimisticLockException extends PersistenceException {
+ private Object entity;
+
+ public OptimisticLockException() {
+ super();
+ }
+
+ public OptimisticLockException(Object entity) {
+ this.entity = entity;
+ }
+
+ public OptimisticLockException(Throwable cause) {
+ super( cause );
+ }
+
+ public OptimisticLockException(String message) {
+ super( message );
+ }
+
+ public OptimisticLockException(String message, Throwable cause) {
+ super( message, cause );
+ }
+
+ public OptimisticLockException(String message, Throwable cause, Object entity) {
+ super( message, cause );
+ this.entity = entity;
+ }
+
+ public Object getEntity() {
+ return entity;
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/OrderBy.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,39 @@
+//$Id: OrderBy.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies the ordering of the elements of a collection valued association at the
+ * point when the association is retrieved.
+ *
+ * The syntax of the value ordering element is an orderby_list, as follows:
+ * <code>orderby_list::= orderby_item [,orderby_item]*
+ * orderby_item::= property_or_field_name [ASC | DESC]</code>
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ * If the ordering element is not specified, ordering by the primary key of the associated
+ * entity is assumed.
+ *
+ * The property or field name must correspond to that of a persistent property or field of the
+ * associated class. The properties or fields used in the ordering must correspond to columns
+ * for which comparison operators are supported.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface OrderBy {
+ /**
+ * An orderby_list, specified as follows:
+ * orderby_list::= orderby_item [,orderby_item]* orderby_item::= property_or_field_name [ASC | DESC]
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ */
+ String value() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Persistence.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,110 @@
+// $Id: Persistence.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.persistence.spi.PersistenceProvider;
+
+/**
+ * Bootstrap class that provides access to an EntityManagerFactory.
+ */
+public class Persistence {
+
+ public static String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
+
+ protected static final Set<PersistenceProvider> providers = new HashSet<PersistenceProvider>();
+
+ /**
+ * Create and return an EntityManagerFactory for the named persistence unit.
+ *
+ * @param persistenceUnitName The name of the persistence unit
+ * @return The factory that creates EntityManagers configured according to the specified persistence unit
+ */
+ public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName) {
+ return createEntityManagerFactory( persistenceUnitName, null );
+ }
+
+ /**
+ * Create and return an EntityManagerFactory for the named persistence unit using the given properties.
+ *
+ * @param persistenceUnitName The name of the persistence unit
+ * @param properties Additional properties to use when creating the factory. The values of these properties override
+ * any values that may have been configured elsewhere
+ * @return The factory that creates EntityManagers configured according to the specified persistence unit
+ */
+ public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
+ EntityManagerFactory emf = null;
+
+ if ( providers.size() == 0 ) {
+ findAllProviders();
+ }
+ for ( PersistenceProvider provider : providers ) {
+ emf = provider.createEntityManagerFactory( persistenceUnitName, properties );
+ if ( emf != null ) break;
+ }
+ if ( emf == null ) {
+ throw new PersistenceException( "No Persistence provider for EntityManager named " + persistenceUnitName );
+ }
+ return emf;
+ }
+
+ // Helper methods
+
+ private static void findAllProviders() {
+ try {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Enumeration<URL> resources = loader.getResources( "META-INF/services/" + PersistenceProvider.class.getName() );
+ Set<String> names = new HashSet<String>();
+ while ( resources.hasMoreElements() ) {
+ URL url = resources.nextElement();
+ InputStream is = url.openStream();
+ try {
+ names.addAll( providerNamesFromReader( new BufferedReader( new InputStreamReader( is ) ) ) );
+ }
+ finally {
+ is.close();
+ }
+ }
+ for ( String s : names ) {
+ Class providerClass = loader.loadClass( s );
+ providers.add( (PersistenceProvider) providerClass.newInstance() );
+ }
+ }
+ catch (IOException e) {
+ throw new PersistenceException( e );
+ }
+ catch (InstantiationException e) {
+ throw new PersistenceException( e );
+ }
+ catch (IllegalAccessException e) {
+ throw new PersistenceException( e );
+ }
+ catch (ClassNotFoundException e) {
+ throw new PersistenceException( e );
+ }
+ }
+
+ private static final Pattern nonCommentPattern = Pattern.compile( "^([^#]+)" );
+
+ private static Set<String> providerNamesFromReader(BufferedReader reader) throws IOException {
+ Set<String> names = new HashSet<String>();
+ String line;
+ while ( ( line = reader.readLine() ) != null ) {
+ line = line.trim();
+ Matcher m = nonCommentPattern.matcher( line );
+ if ( m.find() ) {
+ names.add( m.group().trim() );
+ }
+ }
+ return names;
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContext.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,43 @@
+/* $Id: PersistenceContext.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Expresses a dependency on an EntityManager persistence context.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceContext {
+ /**
+ * The name by which the entity manager is to be accessed in the environment referencing context,
+ * and is not needed when dependency injection is used.
+ */
+ String name() default "";
+ /**
+ * The name of the persistence unit. If the unitName element is specified, the persistence unit
+ * for the entity manager that is accessible in JNDI must have the same name.
+ */
+ String unitName() default "";
+ /**
+ * Used to specify properties for the container or persistence provider. Vendor specific
+ * properties may be included in this set of properties. Properties that are not
+ * recognized by a vendor are ignored.
+ */
+ PersistenceProperty[] properties() default {};
+ /**
+ * Specifies whether this is a transaction-scoped persistence context or
+ * an extended persistence context.
+ */
+ PersistenceContextType type() default PersistenceContextType.TRANSACTION;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContextType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+//$Id: PersistenceContextType.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Specifies whether a transaction-scoped or extended persistence context is to be used in
+ * PersistenceContext. If the type element is not specified, a transaction-scoped persistence
+ * context is used.
+ */
+public enum PersistenceContextType {
+ /**
+ * Transaction-scoped persistence context
+ */
+ TRANSACTION,
+ /**
+ * Extended persistence context
+ */
+ EXTENDED
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceContexts.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,27 @@
+/* $Id: PersistenceContexts.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares one or more PersistenceContext annotations. It is used to express a dependency on
+ * container-managed entity manager persistence contexts.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceContexts {
+ /**
+ * One or more persistence context
+ */
+ PersistenceContext[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,50 @@
+/* $Id: PersistenceException.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss, Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when a problem occurs. All instances of PersistenceException
+ * except for instances of NoResultException and NonUniqueResultException will cause the current
+ * transaction, if one is active, to be marked for rollback.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+public class PersistenceException extends RuntimeException {
+ /**
+ * Constructs a new PersistenceException exception with null as its detail message.
+ */
+ public PersistenceException() {
+ }
+
+ /**
+ * Constructs a new PersistenceException exception with the specified detail message.
+ *
+ * @param message the detail message
+ */
+ public PersistenceException(String message) {
+ super( message );
+ }
+
+ /**
+ * Constructs a new PersistenceException exception with the specified detail message and cause
+ *
+ * @param message the detail message
+ * @param cause the cause
+ */
+ public PersistenceException(String message, Throwable cause) {
+ super( message, cause );
+ }
+
+ /**
+ * Constructs a new PersistenceException exception with the specified cause
+ *
+ * @param cause the cause
+ */
+ public PersistenceException(Throwable cause) {
+ super( cause );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceProperty.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,27 @@
+//$Id: $
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Describes a single container or persistence provider property.
+ * Vendor specific properties may be included in the set of properties, and are passed to the persistence
+ * provider by the container when the entity manager is created.
+ * Properties that are not recognized by a vendor will be ignored.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({})
+@Retention(RUNTIME)
+public @interface PersistenceProperty {
+ /**
+ * The name of the property
+ */
+ String name();
+ /**
+ * The value of the property
+ */
+ String value();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnit.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,33 @@
+/* $Id: PersistenceUnit.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Expresses a dependency on an EntityManagerFactory.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceUnit {
+ /**
+ * The name by which the entity manager factory is to be accessed in the environment
+ * referencing context, and is not needed when dependency injection is used.
+ */
+ String name() default "";
+ /**
+ * The name of the persistence unit as defined in the persistence.xml file. If specified, the
+ * persistence unit for the entity manager factory that is accessible in JNDI must have the
+ * same name.
+ */
+ String unitName() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PersistenceUnits.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,26 @@
+/* $Id: PersistenceUnits.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares one or more PersistenceUnit annotations
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.TYPE})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceUnits {
+ /**
+ * One or more PersistenceUnit annotations
+ */
+ PersistenceUnit[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostLoad.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,24 @@
+/* $Id: PostLoad.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to
+ * methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostLoad {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostPersist.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+/* $Id: PostPersist.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be
+ * applied to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostPersist {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostRemove.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+/* $Id: PostRemove.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostRemove {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PostUpdate.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+/* $Id: PostUpdate.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied to
+ * methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PostUpdate {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PrePersist.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+/* $Id: PrePersist.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PrePersist {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PreRemove.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+/* $Id: PreRemove.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be applied
+ * to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PreRemove {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PreUpdate.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+/* $Id: PreUpdate.java 11171 2007-02-08 03:40:51Z epbernard $
+ * JBoss Inc
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package javax.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Is used to specify callback methods for the corresponding lifecycle event. This annotation may be
+ * applied to methods of an entity class, a mapped superclass, or a callback listener class.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface PreUpdate {
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumn.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,53 @@
+//$Id: PrimaryKeyJoinColumn.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies a primary key column that is used as a foreign key to join to another
+ * table.
+ *
+ * It is used to join the primary table of an entity subclass in the JOINED mapping strategy to
+ * the primary table of its superclass; it is used within a SecondaryTable annotation to join a
+ * secondary table to a primary table; and it may be used in a OneToOne mapping in which the
+ * primary key of the referencing entity is used as a foreign key to the referenced entity.
+ *
+ * If no PrimaryKeyJoinColumn annotation is specified for a subclass in the JOINED mapping
+ * strategy, the foreign key columns are assumed to have the same names as the primary key
+ * columns of the primary table of the superclass
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface PrimaryKeyJoinColumn {
+ /**
+ * The name of the primary key column of the current table.
+ *
+ * Defaults to the same name as the primary key column of the primary table of the
+ * superclass (JOINED mapping strategy); the same name as the primary key column of
+ * the primary table (SecondaryTable mapping); or the same name as the primary key
+ * column for the table for the referencing entity (OneToOne mapping)
+ */
+ String name() default "";
+ /**
+ * The name of the primary key column of the table being joined to.
+ *
+ * Defaults to the same name as the primary key column of the primary table of the
+ * superclass (JOINED mapping strategy); the same name as the primary key column of the
+ * primary table (SecondaryTable mapping); or the same name as the primary key column for
+ * the table for the referencing entity (OneToOne mapping)
+ */
+ String referencedColumnName() default "";
+ /**
+ * The SQL fragment that is used when generating the DDL for the column. This should not be
+ * specified for a OneToOne primary key association.
+ *
+ * Defaults to the generated SQL to create a column of the inferred type.
+ */
+ String columnDefinition() default "";
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/PrimaryKeyJoinColumns.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,22 @@
+//$Id: PrimaryKeyJoinColumns.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation groups PrimaryKeyJoinColumn annotations. It is used to map composite foreign keys.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface PrimaryKeyJoinColumns {
+ /**
+ * One or more PrimaryKeyJoinColumn annotations
+ */
+ PrimaryKeyJoinColumn[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Query.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,148 @@
+// $Id: Query.java 11225 2007-02-20 20:55:29Z epbernard $
+package javax.persistence;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * Interface used to control query execution.
+ */
+public interface Query
+{
+ /**
+ * Execute the query and return the query results as a List.
+ *
+ * @return a list of the results
+ * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
+ */
+ public List getResultList();
+
+ /**
+ * Execute a SELECT query that returns a single result.
+ *
+ * @return the result
+ * @throws NoResultException if there is no result
+ * @throws NonUniqueResultException if more than one result
+ * @throws IllegalStateException if called for a Java
+ * Persistence query language UPDATE or DELETE statement
+ */
+ public Object getSingleResult();
+
+ /**
+ * Execute an update or delete statement.
+ *
+ * @return the number of entities updated or deleted
+ * @throws IllegalStateException if called for a Java Persistence query language SELECT statement
+ * @throws TransactionRequiredException if there is no transaction
+ */
+ public int executeUpdate();
+
+ /**
+ * Set the maximum number of results to retrieve.
+ *
+ * @param maxResult
+ * @return the same query instance
+ * @throws IllegalArgumentException if argument is negative
+ */
+ public Query setMaxResults(int maxResult);
+
+ /**
+ * Set the position of the first result to retrieve.
+ *
+ * @param startPosition position of the first result, numbered from 0
+ * @return the same query instance
+ * @throws IllegalArgumentException if argument is negative
+ */
+ public Query setFirstResult(int startPosition);
+
+ /**
+ * Set an implementation-specific hint. If the hint name is not recognized, it is silently
+ * ignored.
+ *
+ * @param hintName
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if the second argument is not valid for the implementation
+ */
+ public Query setHint(String hintName, Object value);
+
+ /**
+ * Bind an argument to a named parameter.
+ *
+ * @param name the parameter name
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string or argument is of incorrect type
+ */
+ public Query setParameter(String name, Object value);
+
+ /**
+ * Bind an instance of java.util.Date to a named parameter.
+ *
+ * @param name
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string
+ */
+ public Query setParameter(String name, Date value, TemporalType temporalType);
+
+ /**
+ * Bind an instance of java.util.Calendar to a named parameter.
+ *
+ * @param name
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string
+ */
+ public Query setParameter(String name, Calendar value, TemporalType temporalType);
+
+ /**
+ * Bind an argument to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if position does not correspond to positional parameter of
+ * query or argument is of incorrect type
+ */
+ public Query setParameter(int position, Object value);
+
+ /**
+ * Bind an instance of java.util.Date to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if position does not correspond to positional parameter of
+ * query
+ */
+ public Query setParameter(int position, Date value, TemporalType temporalType);
+
+ /**
+ * Bind an instance of java.util.Calendar to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @param temporalType
+ * @return the same query instance } correspond to positional parameter of query
+ */
+ public Query setParameter(int position, Calendar value, TemporalType temporalType);
+
+ /**
+ * Set the flush mode type to be used for the query execution.
+ * The flush mode type applies to the query regardless of the
+ * flush mode type in use for the entity manager.
+ *
+ * @param flushMode
+ */
+ public Query setFlushMode(FlushModeType flushMode);
+
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/QueryHint.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+//$Id: QueryHint.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * An implementation-specific Query hint
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({})
+@Retention(RUNTIME)
+public @interface QueryHint {
+ /**
+ * Name of the hint
+ */
+ String name();
+
+ /**
+ * Value of the hint
+ */
+ String value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/RollbackException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,44 @@
+//$Id: $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when the EntityTransaction.commit() fails
+ *
+ * @author Emmanuel Bernard
+ */
+public class RollbackException extends PersistenceException {
+ /**
+ * Constructs a new RollbackException exception with null as its detail message
+ */
+ public RollbackException() {
+ super();
+ }
+
+ /**
+ * Constructs a new RollbackException exception with the specified cause
+ *
+ * @param cause The detail cause
+ */
+ public RollbackException(Throwable cause) {
+ super( cause );
+ }
+
+ /**
+ * Constructs a new RollbackException exception with the specified detail message
+ *
+ * @param message The detail message
+ */
+ public RollbackException(String message) {
+ super( message );
+ }
+
+ /**
+ * Constructs a new RollbackException exception with the specified detail message and cause
+ *
+ * @param message The detail message
+ * @param cause The detail cause
+ */
+ public RollbackException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTable.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,53 @@
+//$Id: SecondaryTable.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation is used to specify a secondary table for the annotated entity class. Specifying
+ * one or more secondary tables indicates that the data for the entity class is stored across multiple
+ * tables.
+ *
+ * If no SecondaryTable annotation is specified, it is assumed that all persistent fields or properties
+ * of the entity are mapped to the primary table. If no primary key join columns are specified, the
+ * join columns are assumed to reference the primary key columns of the primary table, and have the
+ * same names and types as the referenced primary key columns of the primary table.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface SecondaryTable {
+ /**
+ * The name of the table
+ */
+ String name();
+ /**
+ * The catalog of the table
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table
+ */
+ String schema() default "";
+ /**
+ * The columns that are used to join with the primary table.
+ *
+ * Defaults to the column(s) of the same name(s) as the primary key column(s)
+ * in the primary table
+ */
+ PrimaryKeyJoinColumn[] pkJoinColumns() default {};
+ /**
+ * Unique constraints that are to be placed on the table. These are typically only used if
+ * table generation is in effect. These constraints apply in addition to any constraints
+ * specified by the Column and JoinColumn annotations and constraints entailed by primary
+ * key mappings.
+ *
+ * Defaults to no additional constraints.
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SecondaryTables.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+//$Id: SecondaryTables.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+/**
+ * This annotation is used to specify multiple secondary tables for an entity.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface SecondaryTables {
+ /**
+ * The secondary tables for an entity.
+ */
+ SecondaryTable[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SequenceGenerator.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,38 @@
+//$Id: SequenceGenerator.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation defines a primary key generator that may be referenced by name when a generator
+ * element is specified for the GeneratedValue annotation. A sequence generator may be specified on
+ * the entity class or on the primary key field or property. The scope of the generator name is global
+ * to the persistence unit (across all generator types).
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
+public @interface SequenceGenerator {
+ /**
+ * A unique generator name that can be referenced by one or more classes to be the generator for primary key values
+ */
+ String name();
+ /**
+ * The name of the database sequence object from which to obtain primary key values
+ * Defaults to a provider-chosen value
+ */
+ String sequenceName() default "";
+ /**
+ * The value from which the sequence object is to start generating
+ */
+ int initialValue() default 1;
+ /**
+ * The amount to increment by when allocating sequence numbers from the sequence
+ */
+ int allocationSize() default 50;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMapping.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,29 @@
+//$Id: SqlResultSetMapping.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation is used to specify the mapping of the result of a native SQL query
+ *
+ * @author Emmanuel Bernard
+ */
+(a)Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
+public @interface SqlResultSetMapping {
+ /**
+ * The name given to the result set mapping, and used to refer to it in the methods of the Query API
+ */
+ String name();
+ /**
+ * Specifies the result set mapping to entities
+ */
+ EntityResult[] entities() default {};
+ /**
+ * Specifies the result set mapping to scalar values
+ */
+ ColumnResult[] columns() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/SqlResultSetMappings.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,19 @@
+//$Id: SqlResultSetMapping.java 9044 2006-01-12 20:58:41 -0500 (jeu., 12 janv. 2006) epbernard $
+//EJB3 Specification Copyright 2004 - 2006 Sun Microsystems, Inc.
+
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation is used to define one or more SqlResultSetMapping
+ *
+ * @author Emmanuel Bernard
+ */
+(a)Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME)
+public @interface SqlResultSetMappings {
+ SqlResultSetMapping[] value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Table.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,48 @@
+//$Id: Table.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies the primary table for the annotated entity. Additional
+ * tables may be specified using SecondaryTable or SecondaryTables annotation.
+ *
+ * If no Table annotation is specified for an entity class, the default values apply.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE}) @Retention(RUNTIME)
+public @interface Table {
+ /**
+ * The name of the table.
+ *
+ * Defaults to the entity name.
+ */
+ String name() default "";
+ /**
+ * The catalog of the table.
+ *
+ * Defaults to the default catalog.
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table.
+ *
+ * Defaults to the default schema for user.
+ */
+ String schema() default "";
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table
+ * generation is in effect. These constraints apply in addition to any constraints
+ * specified by the Column and JoinColumn annotations and constraints entailed by
+ * primary key mappings.
+ *
+ * Defaults to no additional constraints.
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/TableGenerator.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,67 @@
+//$Id: TableGenerator.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.*;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation defines a primary key generator that may be referenced by name when a generator
+ * element is specified for the GeneratedValue annotation. A table generator may be specified on the
+ * entity class or on the primary key field or property. The scope of the generator name is global to
+ * the persistence unit (across all generator types).
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface TableGenerator {
+ /**
+ * A unique generator name that can be referenced by one or more classes to be the generator for id values
+ */
+ String name();
+ /**
+ * Name of table that stores the generated id values. Defaults to a name chosen by persistence provider.
+ */
+ String table() default "";
+ /**
+ * The catalog of the table
+ * Defaults to the default catalog
+ */
+ String catalog() default "";
+ /**
+ * The schema of the table
+ * Defaults to the default schema for user
+ */
+ String schema() default "";
+ /**
+ * Name of the primary key column in the table
+ * Defaults to a provider-chosen name
+ */
+ String pkColumnName() default "";
+ /**
+ * Name of the column that stores the last value generated
+ * Defaults to a provider-chosen name
+ */
+ String valueColumnName() default "";
+ /**
+ * The primary key value in the generator table that distinguishes this set of generated values from others that may be stored in the table
+ * Defaults to a provider-chosen value to store in the primary key column of the generator table
+ */
+ String pkColumnValue() default "";
+ /**
+ * The initial value to be used when allocating id numbers from the generator
+ */
+ int initialValue() default 0;
+ /**
+ * The amount to increment by when allocating id numbers from the generator
+ */
+ int allocationSize() default 50;
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table generation is in effect. These constraints apply in addition to primary key constraints
+ * Defaults to no additional constraints
+ */
+ UniqueConstraint[] uniqueConstraints() default {};
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Temporal.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,26 @@
+//$Id: Temporal.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation must be specified for persistent fields or properties of type Date and Calendar.
+ * It may only be specified for fields or properties of these types.
+ *
+ * The Temporal annotation may be used in conjunction with the Basic annotation.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Temporal {
+ /**
+ * The type used in mapping java.util.Date or java.util.Calendar
+ */
+ TemporalType value();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/TemporalType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+//$Id: TemporalType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Type used to indicate a specific mapping of Date or Calendar.
+ */
+public enum TemporalType {
+ /**
+ * Map as java.sql.Date
+ */
+ DATE,
+ /**
+ * Map as java.sql.Time
+ */
+ TIME,
+ /**
+ * Map as java.sql.Timestamp
+ */
+ TIMESTAMP
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/TransactionRequiredException.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,26 @@
+//$Id: TransactionRequiredException.java 11171 2007-02-08 03:40:51Z epbernard $
+package javax.persistence;
+
+/**
+ * Thrown by the persistence provider when a transaction is required but is not active.
+ * @author Gavin King
+ */
+public class TransactionRequiredException extends PersistenceException {
+
+ /**
+ * Constructs a new TransactionRequiredException exception with null as its detail message
+ */
+ public TransactionRequiredException() {
+ super();
+ }
+
+ /**
+ * Constructs a new TransactionRequiredException exception with the specified detail message
+ *
+ * @param message
+ */
+ public TransactionRequiredException(String message) {
+ super( message );
+ }
+
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Transient.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+//$Id: Transient.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies that the property or field is not persistent. It is used to annotate
+ * a property or field of an entity class, mapped superclass, or embeddable class.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Transient {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/UniqueConstraint.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+//$Id: UniqueConstraint.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used to specify that a unique constraint is to be included in the generated DDL
+ * for a primary or secondary table
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({}) @Retention(RUNTIME)
+public @interface UniqueConstraint {
+ /**
+ * An array of the column names that make up the constraint
+ */
+ String[] columnNames();
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/Version.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,28 @@
+//$Id: Version.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * This annotation specifies the version field or property of an entity class that serves as its
+ * optimistic lock value. The version is used to ensure integrity when performing the merge
+ * operation and for optimistic concurrency control.
+ *
+ * Only a single Version property or field should be used per class; applications that use more
+ * than one Version property or field will not be portable.
+ *
+ * The Version property should be mapped to the primary table for the entity class; applications
+ * that map the Version property to a table other than the primary table will not be portable.
+ *
+ * The following types are supported for version properties: int, Integer, short, Short, long,
+ * Long, Timestamp.
+ *
+ * @author Emmanuel Bernard
+ */
+@Target({METHOD, FIELD}) @Retention(RUNTIME)
+public @interface Version {}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/package-info.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,9 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+
+/**
+ * The javax.persistence package contains the classes and interfaces that define the contracts
+ * between a persistence provider and the managed classes and the clients of the Java Persistence API.
+ */
+package javax.persistence;
+
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/ClassTransformer.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,39 @@
+//$Id: ClassTransformer.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence.spi;
+
+import java.security.ProtectionDomain;
+import java.lang.instrument.IllegalClassFormatException;
+
+/**
+ * A persistence provider provides an instance of this interface
+ * to the PersistenceUnitInfo.addTransformer method.
+ * The supplied transformer instance will get called to transform
+ * entity class files when they are loaded and redefined. The transformation
+ * occurs before the class is defined by the JVM
+ *
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @version $Revision: 11171 $
+ */
+public interface ClassTransformer
+{
+ /**
+ * Invoked when a class is being loaded or redefined to add hooks for persistence bytecode manipulation
+ *
+ * @param loader the defining class loaderof the class being transformed. It may be null if using bootstrap loader
+ * @param classname The name of the class being transformed
+ * @param classBeingRedefined If an already loaded class is being redefined, then pass this as a parameter
+ * @param protectionDomain ProtectionDomain of the class being (re)-defined
+ * @param classfileBuffer The input byte buffer in class file format
+ * @return A well-formed class file that can be loaded
+ *
+ * @throws IllegalClassFormatException
+ */
+ byte[] transform(ClassLoader loader,
+ String classname,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer)
+ throws IllegalClassFormatException;
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceProvider.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,43 @@
+//$Id: PersistenceProvider.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence.spi;
+
+import java.util.Map;
+import javax.persistence.EntityManagerFactory;
+
+/**
+ * Interface implemented by the persistence provider.
+ * This interface is used to create an EntityManagerFactory.
+ * It is invoked by the container in Java EE environments and
+ * by the Persistence class in Java SE environments.
+ */
+public interface PersistenceProvider {
+ /**
+ * Called by Persistence class when an EntityManagerFactory
+ * is to be created.
+ *
+ * @param emName The name of the persistence unit
+ * @param map A Map of properties for use by the
+ * persistence provider. These properties may be used to
+ * override the values of the corresponding elements in
+ * the persistence.xml file or specify values for
+ * properties not specified in the persistence.xml
+ * (and may be null if no properties are specified).
+ * @return EntityManagerFactory for the persistence unit,
+ * or null if the provider is not the right provider
+ */
+ public EntityManagerFactory createEntityManagerFactory(String emName, Map map);
+
+ /**
+ * Called by the container when an EntityManagerFactory
+ * is to be created.
+ *
+ * @param info Metadata for use by the persistence provider
+ * @param map A Map of integration-level properties for use
+ * by the persistence provider (may be null if no properties
+ * are specified).
+ * @return EntityManagerFactory for the persistence unit
+ * specified by the metadata
+ */
+ public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map);
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitInfo.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,142 @@
+//$Id: PersistenceUnitInfo.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.package javax.persistence.spi;
+package javax.persistence.spi;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+import javax.sql.DataSource;
+
+/**
+ * Interface implemented by the container and used by the
+ * persistence provider when creating an EntityManagerFactory.
+ */
+public interface PersistenceUnitInfo {
+ /**
+ * @return The name of the persistence unit.
+ * Corresponds to the <name> element in the persistence.xml file.
+ */
+ public String getPersistenceUnitName();
+
+ /**
+ * @return The fully qualified name of the persistence provider
+ * implementation class.
+ * Corresponds to the <provider> element in the persistence.xml
+ * file.
+ */
+ public String getPersistenceProviderClassName();
+
+ /**
+ * @return The transaction type of the entity managers created
+ * by the EntityManagerFactory.
+ * The transaction type corresponds to the transaction-type
+ * attribute in the persistence.xml file.
+ */
+ public PersistenceUnitTransactionType getTransactionType();
+
+ /**
+ * @return The JTA-enabled data source to be used by the
+ * persistence provider.
+ * The data source corresponds to the <jta-data-source>
+ * element in the persistence.xml file or is provided at
+ * deployment or by the container.
+ */
+ public DataSource getJtaDataSource();
+
+ /**
+ * @return The non-JTA-enabled data source to be used by the
+ * persistence provider for accessing data outside a JTA
+ * transaction.
+ * The data source corresponds to the named <non-jta-data-source>
+ * element in the persistence.xml file or provided at
+ * deployment or by the container.
+ */
+ public DataSource getNonJtaDataSource();
+
+ /**
+ * @return The list of mapping file names that the persistence
+ * provider must load to determine the mappings for the entity
+ * classes. The mapping files must be in the standard XML
+ * mapping format, be uniquely named and be resource-loadable
+ * from the application classpath.
+ * Each mapping file name corresponds to a <mapping-file>
+ * element in the persistence.xml file.
+ */
+ public List<String> getMappingFileNames();
+
+ /**
+ * @return The list of JAR file URLs that the persistence
+ * provider must examine for managed classes of the persistence
+ * unit. Each jar file URL corresponds to a named <jar-file>
+ * element in the persistence.xml file.
+ */
+ public List<URL> getJarFileUrls();
+
+ /**
+ * @return The URL for the jar file or directory that is the
+ * root of the persistence unit. (If the persistence unit is
+ * rooted in the WEB-INF/classes directory, this will be the
+ * URL of that directory.)
+ */
+ public URL getPersistenceUnitRootUrl();
+
+ /**
+ * @return The list of the names of the classes that the
+ * persistence provider must add it to its set of managed
+ * classes. Each name corresponds to a named <class> element
+ * in the persistence.xml file.
+ */
+ public List<String> getManagedClassNames();
+
+ /**
+ * @return Whether classes in the root of the persistence
+ * unit that have not been explicitly listed are to be
+ * included in the set of managed classes.
+ * This value corresponds to the <exclude-unlisted-classes>
+ * element in the persistence.xml file.
+ */
+ public boolean excludeUnlistedClasses();
+
+ /**
+ * @return Properties object. Each property corresponds
+ * to a <property> element in the persistence.xml file
+ */
+ public Properties getProperties();
+
+ /**
+ * @return ClassLoader that the provider may use to load any
+ * classes, resources, or open URLs.
+ */
+ public ClassLoader getClassLoader();
+
+ /**
+ * Add a transformer supplied by the provider that will be
+ * called for every new class definition or class redefinition
+ * that gets loaded by the loader returned by the
+ * PersistenceInfo.getClassLoader method. The transformer
+ * has no effect on the result returned by the
+ * PersistenceInfo.getTempClassLoader method.
+ * Classes are only transformed once within the same classloading
+ * scope, regardless of how many persistence units they may be
+ * a part of.
+ *
+ * @param transformer A provider-supplied transformer that the
+ * Container invokes at class-(re)definition time
+ */
+ public void addTransformer(ClassTransformer transformer);
+
+ /**
+ * Return a new instance of a ClassLoader that the provider
+ * may use to temporarily load any classes, resources, or
+ * open URLs. The scope and classpath of this loader is
+ * exactly the same as that of the loader returned by
+ * PersistenceInfo.getClassLoader. None of the classes loaded
+ * by this class loader will be visible to application
+ * components. The container does not use or maintain references
+ * to this class loader after returning it to the provider.
+ *
+ * @return Temporary ClassLoader with same visibility as current
+ * loader
+ */
+ public ClassLoader getNewTempClassLoader();
+}
\ No newline at end of file
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/PersistenceUnitTransactionType.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,20 @@
+//$Id: PersistenceUnitTransactionType.java 11171 2007-02-08 03:40:51Z epbernard $
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+package javax.persistence.spi;
+
+/**
+ * This enum class defines whether the entity managers created by the EntityManagerFactory will be
+ * JTA or resource-local entity managers.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ */
+public enum PersistenceUnitTransactionType {
+ /**
+ * JTA entity manager
+ */
+ JTA,
+ /**
+ * Resource-local entity manager
+ */
+ RESOURCE_LOCAL
+}
Added: workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java
===================================================================
--- workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java (rev 0)
+++ workspace/max/jpaap/javax.persistence/src/javax/persistence/spi/package-info.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,10 @@
+//$Id:$
+//EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc.
+
+/**
+ * The javax.persistence.spi package defines the classes and interfaces that are implemented by the
+ * persistence provider and the Java EE container for use by the container, provider, and/or Persistence
+ * bootstrap class in deployment and bootstrapping.
+ */
+package javax.persistence.spi;
+
Added: workspace/max/jpaap/jpaap/.classpath
===================================================================
--- workspace/max/jpaap/jpaap/.classpath (rev 0)
+++ workspace/max/jpaap/jpaap/.classpath 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/javax.persistence"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/max/jpaap/jpaap/.project
===================================================================
--- workspace/max/jpaap/jpaap/.project (rev 0)
+++ workspace/max/jpaap/jpaap/.project 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jpaap</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
Added: workspace/max/jpaap/jpaap/META-INF/MANIFEST.MF
===================================================================
--- workspace/max/jpaap/jpaap/META-INF/MANIFEST.MF (rev 0)
+++ workspace/max/jpaap/jpaap/META-INF/MANIFEST.MF 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: jpaap
+Bundle-SymbolicName: jpaap
+Bundle-Version: 1.0.0
+Export-Package: org.jboss.jpa.metamodel.ap
+Bundle-ClassPath: jpaap.jar
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: workspace/max/jpaap/jpaap/bin/META-INF/services/javax.annotation.processing.Processor
===================================================================
--- workspace/max/jpaap/jpaap/bin/META-INF/services/javax.annotation.processing.Processor (rev 0)
+++ workspace/max/jpaap/jpaap/bin/META-INF/services/javax.annotation.processing.Processor 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1 @@
+org.jboss.jpa.metamodel.ap.JPAMetaModelEntityProcessor
\ No newline at end of file
Added: workspace/max/jpaap/jpaap/build.properties
===================================================================
--- workspace/max/jpaap/jpaap/build.properties (rev 0)
+++ workspace/max/jpaap/jpaap/build.properties 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,4 @@
+source.jpaap.jar = src/
+bin.includes = META-INF/,\
+ jpaap.jar
+source.jpaap.jar = src/
Added: workspace/max/jpaap/jpaap/build.xml
===================================================================
--- workspace/max/jpaap/jpaap/build.xml (rev 0)
+++ workspace/max/jpaap/jpaap/build.xml 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- WARNING: Eclipse auto-generated file.
+ Any modifications will be overwritten.
+ To include a user specific buildfile here, simply create one in the same
+ directory with the processing instruction <?eclipse.ant.import?>
+ as the first entry and export the buildfile again. -->
+<project basedir="." default="build" name="jpaap">
+ <property environment="env"/>
+ <property name="test.location" value="../test"/>
+ <property name="javax.persistence.location" value="../javax.persistence"/>
+ <property name="debuglevel" value="source,lines,vars"/>
+ <property name="target" value="1.6"/>
+ <property name="source" value="1.6"/>
+ <path id="Plug-in Dependencies.libraryclasspath"/>
+ <path id="javax.persistence.classpath">
+ <pathelement location="${javax.persistence.location}/classes"/>
+ <pathelement location="${javax.persistence.location}/bin"/>
+ <path refid="Plug-in Dependencies.libraryclasspath"/>
+ </path>
+ <path id="jpaap.classpath">
+ <pathelement location="bin"/>
+ <path refid="Plug-in Dependencies.libraryclasspath"/>
+ <path refid="javax.persistence.classpath"/>
+ </path>
+ <target name="init">
+ <mkdir dir="bin"/>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="src" excludes="**/*.launch, **/*.java"/>
+ </copy>
+ </target>
+ <target name="clean">
+ <delete dir="bin"/>
+ </target>
+ <target depends="clean" name="cleanall">
+ <ant antfile="${javax.persistence.location}/build.xml" inheritAll="false" target="clean"/>
+ </target>
+ <target depends="build-subprojects,build-project" name="build"/>
+ <target name="build-subprojects">
+ <ant antfile="${javax.persistence.location}/build.xml" inheritAll="false" target="build-project"/>
+ </target>
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="src"/>
+ <classpath refid="jpaap.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects">
+ <ant antfile="${test.location}/build.xml" inheritAll="false" target="clean"/>
+ <ant antfile="${test.location}/build.xml" inheritAll="false" target="build"/>
+ </target>
+</project>
Added: workspace/max/jpaap/jpaap/jpaap.jar
===================================================================
(Binary files differ)
Property changes on: workspace/max/jpaap/jpaap/jpaap.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/max/jpaap/jpaap/jpaap.jardesc
===================================================================
--- workspace/max/jpaap/jpaap/jpaap.jardesc (rev 0)
+++ workspace/max/jpaap/jpaap/jpaap.jardesc 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
+<jardesc>
+ <jar path="jpaap/jpaap.jar"/>
+ <options buildIfNeeded="true" compress="true" descriptionLocation="/jpaap/jpaap.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
+ <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
+ <selectedProjects/>
+ <manifest generateManifest="false" manifestLocation="/jpaap/META-INF/MANIFEST.MF" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
+ <sealing sealJar="false">
+ <packagesToSeal/>
+ <packagesToUnSeal/>
+ </sealing>
+ </manifest>
+ <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
+ <folder path="/jpaap/META-INF"/>
+ <javaElement handleIdentifier="=jpaap/src"/>
+ </selectedElements>
+ <fatjar builder="org.eclipse.jdt.ui.plain_jar_builder" launchConfig=""/>
+</jardesc>
Added: workspace/max/jpaap/jpaap/readme.txt
===================================================================
--- workspace/max/jpaap/jpaap/readme.txt (rev 0)
+++ workspace/max/jpaap/jpaap/readme.txt 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,5 @@
+Project contains the src for the Java 6 annotation processor.
+
+jpaap.jar is the jar to use with javac or Eclipse annotation processor.
+
+To regenerate right click jpaap.jardesc and click Create Jar
\ No newline at end of file
Added: workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor
===================================================================
--- workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor (rev 0)
+++ workspace/max/jpaap/jpaap/src/META-INF/services/javax.annotation.processing.Processor 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1 @@
+org.jboss.jpa.metamodel.ap.JPAMetaModelEntityProcessor
\ No newline at end of file
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContext.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+package org.jboss.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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/ImportContextImpl.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,160 @@
+package org.jboss.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;
+
+ 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,152 @@
+package org.jboss.jpa.metamodel.ap;
+
+import static javax.lang.model.SourceVersion.RELEASE_6;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Generated;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.FilerException;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.FileObject;
+
+@SupportedAnnotationTypes("javax.persistence.Entity")
+@SupportedSourceVersion(RELEASE_6)
+public class JPAMetaModelEntityProcessor extends AbstractProcessor {
+
+ public JPAMetaModelEntityProcessor() {
+
+ }
+
+ /**
+ * 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) {
+
+
+ if(aRoundEnvironment.processingOver()) { // No need to run since all our output needs to be considered
+ return false;
+ }
+
+ Set<? extends Element> elements = aRoundEnvironment.getRootElements();
+
+ 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(MetaEntity entity) {
+
+ try {
+ Name metaModelPackage = entity.getPackageName();
+
+
+ StringBuffer body = generateBody(entity);
+
+ FileObject fo = processingEnv.getFiler().createSourceFile(
+ metaModelPackage + "." + entity.getSimpleName() + "_",
+ entity.getOriginalElement());
+ 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(MetaEntity 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.jpa.metamodel.TypesafeMetamodel"));
+
+ pw.println("public abstract class " + entity.getSimpleName() + "_" + " {");
+
+ pw.println();
+
+ List<MetaMember> members = entity.getMembers();
+
+ for (MetaMember metaMember : members) {
+ pw.println( " " + metaMember.getDeclarationString() );
+ }
+ pw.println();
+ pw.println("}");
+ return sw.getBuffer();
+ } finally {
+ if (pw!=null) pw.close();
+ }
+
+
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JpaAnnotationsConstants.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,33 @@
+package org.jboss.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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaAttribute.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,16 @@
+package org.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Element;
+
+public class MetaAttribute extends MetaMember {
+
+ public MetaAttribute(MetaEntity parent, Element element, String type) {
+ super(parent, element, type);
+ }
+
+ @Override
+ protected String getMetaType() {
+ return "javax.jpa.metamodel.Attribute";
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaCollection.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,22 @@
+package org.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Element;
+
+
+public class MetaCollection extends MetaMember {
+
+ private String collectionType;
+
+
+ public MetaCollection(MetaEntity parent, Element element, String collectionType, String elementType) {
+ super(parent, element, elementType);
+ this.collectionType = collectionType;
+ }
+
+ @Override
+ protected String getMetaType() {
+ return collectionType;
+ }
+
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,224 @@
+package org.jboss.jpa.metamodel.ap;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.PrimitiveType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.SimpleTypeVisitor6;
+import javax.tools.Diagnostic.Kind;
+
+public class MetaEntity implements ImportContext {
+
+ 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 Name getSimpleName() {
+ return element.getSimpleName();
+ }
+
+ public Element getOriginalElement() {
+ return element;
+ }
+
+ public Name getQualifiedName() {
+ return element.getQualifiedName();
+ }
+
+ public Name getPackageName() {
+ PackageElement packageOf = pe.getElementUtils().getPackageOf(element);
+ return pe.getElementUtils().getName(packageOf.getQualifiedName() + ".metamodel");
+ }
+
+ public List<MetaMember> getMembers() {
+
+ List<MetaMember> members = new ArrayList<MetaMember>();
+
+ if(useFields()) {
+
+ List<? extends Element> myMembers = ElementFilter.fieldsIn(element.getEnclosedElements());
+
+ System.out.println("Scanning " + myMembers.size() + " field s for " + element.toString());
+
+ for (Element mymember : myMembers) {
+
+ MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
+ if(result!=null) {
+ members.add(result);
+ } else {
+ pe.getMessager().printMessage(Kind.WARNING, "Could not find valid info for JPA property", mymember);
+ }
+ }
+
+ } else {
+
+
+ List<? extends Element> myMembers = ElementFilter.methodsIn(element.getEnclosedElements());
+
+ System.out.println("Scanning " + myMembers.size() + " methods for " + element.toString());
+ for (Element mymember : myMembers) {
+
+ MetaMember result = mymember.asType().accept(new TypeVisitor(this), mymember);
+ if(result!=null) {
+ members.add(result);
+ } else {
+ //pe.getMessager().printMessage(Kind.WARNING, "Not a valid JPA property", mymember);
+ }
+ }
+
+ }
+
+ if(members.size()==0) {
+ pe.getMessager().printMessage(Kind.WARNING, "No properties found on " + element, element);
+ }
+ return members;
+ }
+
+
+ //TODO: Find more efficient way to identify wether we should use fields or properties
+ private boolean useFields() {
+ List<? extends Element> myMembers = element.getEnclosedElements();
+ for (Element element : myMembers) {
+ List<? extends AnnotationMirror> entityAnnotations =
+ pe.getElementUtils().getAllAnnotationMirrors(element);
+
+ for (Iterator<?> iterator = entityAnnotations.iterator(); iterator
+ .hasNext();) {
+ AnnotationMirror annotationMirror = (AnnotationMirror) iterator
+ .next();
+
+ final String annotationType = annotationMirror.getAnnotationType().toString();
+
+ if ( annotationType.equals(javax.persistence.Id.class.getName()) ||
+ annotationType.equals(javax.persistence.EmbeddedId.class.getName()))
+ {
+ if(element.getKind()==ElementKind.FIELD) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+
+ static Map<String, String> COLLECTIONS = new HashMap<String, String>();
+ static {
+ COLLECTIONS.put("java.util.Collection", "javax.jpa.metamodel.Collection");
+ COLLECTIONS.put("java.util.Set", "javax.jpa.metamodel.Set");
+ COLLECTIONS.put("java.util.List", "javax.jpa.metamodel.List");
+ COLLECTIONS.put("java.util.Map", "javax.jpa.metamodel.Map");
+ }
+
+ class TypeVisitor extends SimpleTypeVisitor6<MetaMember, Element> {
+
+ MetaEntity parent;
+
+ TypeVisitor(MetaEntity parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ protected MetaMember defaultAction(TypeMirror e, Element p) {
+ //System.out.println("Default action for: " + e + " on " + p);
+ //new Exception().printStackTrace();
+ return super.defaultAction(e, p);
+ }
+ @Override
+ public MetaMember visitPrimitive(PrimitiveType t, Element p) {
+ return new MetaAttribute(parent, p, TypeUtils.toTypeString(t));
+ }
+
+
+
+ @Override
+ public MetaMember visitDeclared(DeclaredType t, Element p) {
+ TypeElement e = (TypeElement) pe.getTypeUtils().asElement(t);
+
+ String collection = COLLECTIONS.get(e.getQualifiedName().toString()); // WARNING: .toString() is necessary here since Name equals does not compare to String
+ if(collection!=null) {
+ if(collection.equals("javax.jpa.metamodel.Map")) {
+ return new MetaMap(parent, p, collection, getKeyType(t), getElementType(t));
+ } else {
+ return new MetaCollection(parent, p, collection, getElementType(t));
+ }
+ } else {
+ return new MetaAttribute(parent, p, e.getQualifiedName().toString());
+ }
+ }
+
+
+
+ @Override
+ public MetaMember visitExecutable(ExecutableType t, Element p) {
+ String string = p.getSimpleName().toString();
+
+ // TODO: implement proper property get/is/boolean detection
+ if(string.startsWith("get") || string.startsWith("is")) {
+ TypeMirror returnType = t.getReturnType();
+
+ return returnType.accept(this, p);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public String generateImports() {
+ return importContext.generateImports();
+ }
+
+ @Override
+ public String importType(String fqcn) {
+ return importContext.importType(fqcn);
+ }
+
+ @Override
+ 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: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMap.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,19 @@
+package org.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Element;
+
+public class MetaMap extends MetaCollection {
+
+ private final String keyType;
+
+ public MetaMap(MetaEntity parent, Element element, String collectionType,
+ String keyType, String elementType) {
+ super(parent, element, collectionType, elementType);
+ this.keyType = keyType;
+ }
+
+ public String getDeclarationString() {
+ return "public static " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,52 @@
+package org.jboss.jpa.metamodel.ap;
+
+import java.beans.Introspector;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Name;
+
+public abstract class MetaMember {
+
+ final protected Element element;
+ final protected MetaEntity parent;
+ final protected ProcessingEnvironment pe;
+ private final String type;
+
+ public MetaMember(MetaEntity parent, Element element, String type) {
+ this.element = element;
+ this.parent = parent;
+ this.type = type;
+ this.pe = parent.pe;
+ }
+
+ public String getDeclarationString() {
+ return "public static " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
+ }
+
+ protected Name getPropertyName() {
+ if(element.getKind()==ElementKind.FIELD) {
+ return element.getSimpleName();
+ } else if (element.getKind()==ElementKind.METHOD) {
+
+ String name = element.getSimpleName().toString();
+ if(name.startsWith("get")) {
+ return pe.getElementUtils().getName(Introspector.decapitalize(name.substring("get".length())));
+ } else if(name.startsWith("is")) {
+ return (pe.getElementUtils().getName(Introspector.decapitalize(name.substring("is".length()))));
+ }
+ return pe.getElementUtils().getName(Introspector.decapitalize(name));
+ } else {
+ return pe.getElementUtils().getName(element.getSimpleName() + "/* " + element.getKind() + " */");
+ }
+ }
+
+ abstract protected String getMetaType();
+
+
+ protected String getTypeDeclaration() {
+ return type;
+ }
+
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java (rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/TypeUtils.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,33 @@
+package org.jboss.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: workspace/max/jpaap/org.jboss.jpa.metamodel/.classpath
===================================================================
--- workspace/max/jpaap/org.jboss.jpa.metamodel/.classpath (rev 0)
+++ workspace/max/jpaap/org.jboss.jpa.metamodel/.classpath 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/max/jpaap/org.jboss.jpa.metamodel/.project
===================================================================
--- workspace/max/jpaap/org.jboss.jpa.metamodel/.project (rev 0)
+++ workspace/max/jpaap/org.jboss.jpa.metamodel/.project 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.jpa.metamodel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: workspace/max/jpaap/org.jboss.jpa.metamodel/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- workspace/max/jpaap/org.jboss.jpa.metamodel/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ workspace/max/jpaap/org.jboss.jpa.metamodel/.settings/org.eclipse.jdt.core.prefs 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,7 @@
+#Fri Jan 16 14:06:39 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: workspace/max/jpaap/org.jboss.jpa.metamodel/META-INF/MANIFEST.MF
===================================================================
--- workspace/max/jpaap/org.jboss.jpa.metamodel/META-INF/MANIFEST.MF (rev 0)
+++ workspace/max/jpaap/org.jboss.jpa.metamodel/META-INF/MANIFEST.MF 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Metamodel Plug-in
+Bundle-SymbolicName: org.jboss.jpa.metamodel;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: jpaap;bundle-version="1.0.0",
+ org.eclipse.jdt.apt.core;bundle-version="3.3.101"
+Bundle-ClassPath: .
Added: workspace/max/jpaap/org.jboss.jpa.metamodel/build.properties
===================================================================
--- workspace/max/jpaap/org.jboss.jpa.metamodel/build.properties (rev 0)
+++ workspace/max/jpaap/org.jboss.jpa.metamodel/build.properties 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: workspace/max/jpaap/org.jboss.jpa.metamodel/plugin.xml
===================================================================
--- workspace/max/jpaap/org.jboss.jpa.metamodel/plugin.xml (rev 0)
+++ workspace/max/jpaap/org.jboss.jpa.metamodel/plugin.xml 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
+ <java6processors
+ enableDefault="true">
+ <java6processor
+ class="org.jboss.jpa.metamodel.ap.JPAMetaModelEntityProcessor">
+ </java6processor>
+ </java6processors>
+ </extension>
+
+</plugin>
Added: workspace/max/jpaap/test/.classpath
===================================================================
--- workspace/max/jpaap/test/.classpath (rev 0)
+++ workspace/max/jpaap/test/.classpath 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry excluding="**/*.class" kind="src" path="build/classes"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="gen-src">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry combineaccessrules="false" kind="src" path="/javax.persistence"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jpaap"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/max/jpaap/test/.factorypath
===================================================================
--- workspace/max/jpaap/test/.factorypath (rev 0)
+++ workspace/max/jpaap/test/.factorypath 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,4 @@
+<factorypath>
+ <factorypathentry kind="WKSPJAR" id="/jpaap/jpaap.jar" enabled="false" runInBatchMode="false"/>
+ <factorypathentry kind="WKSPJAR" id="/javax.persistence/jpa.jar" enabled="false" runInBatchMode="false"/>
+</factorypath>
Added: workspace/max/jpaap/test/.project
===================================================================
--- workspace/max/jpaap/test/.project (rev 0)
+++ workspace/max/jpaap/test/.project 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: workspace/max/jpaap/test/.settings/org.eclipse.jdt.apt.core.prefs
===================================================================
--- workspace/max/jpaap/test/.settings/org.eclipse.jdt.apt.core.prefs (rev 0)
+++ workspace/max/jpaap/test/.settings/org.eclipse.jdt.apt.core.prefs 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,5 @@
+#Fri Jan 16 13:37:51 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=true
+org.eclipse.jdt.apt.genSrcDir=gen-src
+org.eclipse.jdt.apt.reconcileEnabled=true
Added: workspace/max/jpaap/test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- workspace/max/jpaap/test/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ workspace/max/jpaap/test/.settings/org.eclipse.jdt.core.prefs 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,3 @@
+#Fri Jan 16 13:37:51 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
Added: workspace/max/jpaap/test/build/classes/model/metamodel/Item_.java
===================================================================
--- workspace/max/jpaap/test/build/classes/model/metamodel/Item_.java (rev 0)
+++ workspace/max/jpaap/test/build/classes/model/metamodel/Item_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,22 @@
+package model.metamodel;
+
+import javax.annotation.Generated;
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Map;
+import javax.jpa.metamodel.TypesafeMetamodel;
+import model.Item;
+import model.Order;
+import model.Product;
+
+@Generated("JPA MetaModel for model.Item")
+@TypesafeMetamodel
+public abstract class Item_ {
+
+ public static Attribute<Item, Long> id;
+ public static Attribute<Item, Integer> quantity;
+ public static Attribute<Item, Product> product;
+ public static Attribute<Item, Order> order;
+ public static Map<Item, String, Order> namedOrders;
+
+}
+
Added: workspace/max/jpaap/test/build/classes/model/metamodel/Order_.java
===================================================================
--- workspace/max/jpaap/test/build/classes/model/metamodel/Order_.java (rev 0)
+++ workspace/max/jpaap/test/build/classes/model/metamodel/Order_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+package model.metamodel;
+
+import java.util.Date;
+import javax.annotation.Generated;
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.List;
+import javax.jpa.metamodel.Set;
+import javax.jpa.metamodel.TypesafeMetamodel;
+import model.Item;
+import model.Order;
+import model.Shop;
+
+@Generated("JPA MetaModel for model.Order")
+@TypesafeMetamodel
+public abstract class Order_ {
+
+ public static Attribute<Order, Long> id;
+ public static Set<Order, Item> items;
+ public static Attribute<Order, Boolean> filled;
+ public static Attribute<Order, Date> date;
+ public static List<Order, String> notes;
+ public static Attribute<Order, Shop> shop;
+
+}
+
Added: workspace/max/jpaap/test/build/classes/model/metamodel/Product_.java
===================================================================
--- workspace/max/jpaap/test/build/classes/model/metamodel/Product_.java (rev 0)
+++ workspace/max/jpaap/test/build/classes/model/metamodel/Product_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+package model.metamodel;
+
+import java.math.BigDecimal;
+import javax.annotation.Generated;
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Set;
+import javax.jpa.metamodel.TypesafeMetamodel;
+import model.Item;
+import model.Product;
+import model.Shop;
+
+@Generated("JPA MetaModel for model.Product")
+@TypesafeMetamodel
+public abstract class Product_ {
+
+ public static Attribute<Product, Long> id;
+ public static Attribute<Product, String> description;
+ public static Attribute<Product, BigDecimal> price;
+ public static Attribute<Product, Shop> shop;
+ public static Set<Product, Item> items;
+
+}
+
Added: workspace/max/jpaap/test/build/classes/model/metamodel/Shop_.java
===================================================================
--- workspace/max/jpaap/test/build/classes/model/metamodel/Shop_.java (rev 0)
+++ workspace/max/jpaap/test/build/classes/model/metamodel/Shop_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,16 @@
+package model.metamodel;
+
+import javax.annotation.Generated;
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.TypesafeMetamodel;
+import model.Shop;
+
+@Generated("JPA MetaModel for model.Shop")
+@TypesafeMetamodel
+public abstract class Shop_ {
+
+ public static Attribute<Shop, Long> id;
+ public static Attribute<Shop, String> name;
+
+}
+
Added: workspace/max/jpaap/test/build.xml
===================================================================
--- workspace/max/jpaap/test/build.xml (rev 0)
+++ workspace/max/jpaap/test/build.xml 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- WARNING: Eclipse auto-generated file.
+ Any modifications will be overwritten.
+ To include a user specific buildfile here, simply create one in the same
+ directory with the processing instruction <?eclipse.ant.import?>
+ as the first entry and export the buildfile again. -->
+<project basedir="." default="build" name="test">
+ <property environment="env"/>
+ <property name="javax.persistence.location" value="../javax.persistence"/>
+ <property name="jpaap.location" value="../jpaap"/>
+ <property name="debuglevel" value="source,lines,vars"/>
+ <property name="target" value="1.6"/>
+ <property name="source" value="1.6"/>
+ <path id="Plug-in Dependencies.libraryclasspath"/>
+ <path id="javax.persistence.classpath">
+ <pathelement location="${javax.persistence.location}/classes"/>
+ <pathelement location="${javax.persistence.location}/bin"/>
+ <path refid="Plug-in Dependencies.libraryclasspath"/>
+ </path>
+ <path id="jpaap.classpath">
+ <pathelement location="${jpaap.location}/bin"/>
+ <path refid="Plug-in Dependencies.libraryclasspath"/>
+ <path refid="javax.persistence.classpath"/>
+ </path>
+ <path id="test.classpath">
+ <pathelement location="bin"/>
+ <path refid="javax.persistence.classpath"/>
+ <path refid="jpaap.classpath"/>
+ </path>
+ <target name="init">
+ <mkdir dir="bin"/>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="build/classes" excludes="**/*.launch, **/*.java"/>
+ </copy>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="src" excludes="**/*.launch, **/*.java"/>
+ </copy>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="gen-src" excludes="**/*.launch, **/*.java"/>
+ </copy>
+ </target>
+ <target name="clean">
+ <delete dir="bin"/>
+ </target>
+ <target depends="clean" name="cleanall">
+ <ant antfile="${javax.persistence.location}/build.xml" inheritAll="false" target="clean"/>
+ <ant antfile="${jpaap.location}/build.xml" inheritAll="false" target="clean"/>
+ </target>
+ <target depends="build-subprojects,build-project" name="build"/>
+ <target name="build-subprojects">
+ <ant antfile="${javax.persistence.location}/build.xml" inheritAll="false" target="build-project"/>
+ <ant antfile="${jpaap.location}/build.xml" inheritAll="false" target="build-project"/>
+ </target>
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="build/classes"/>
+ <classpath refid="test.classpath"/>
+ </javac>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="src"/>
+ <classpath refid="test.classpath"/>
+ </javac>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="gen-src"/>
+ <classpath refid="test.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
+</project>
Added: workspace/max/jpaap/test/goal/metamodel/Item_.java
===================================================================
--- workspace/max/jpaap/test/goal/metamodel/Item_.java (rev 0)
+++ workspace/max/jpaap/test/goal/metamodel/Item_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,17 @@
+package metamodel;
+
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.TypesafeMetamodel;
+
+import model.Item;
+import model.Order;
+import model.Product;
+
+/* @Generated by javac */
+@TypesafeMetamodel
+public abstract class Item_ {
+ public static Attribute<Item, Long> id;
+ public static Attribute<Item, Product> product;
+ public static Attribute<Item, Order> order;
+ public static Attribute<Item, Integer> quantity;
+}
Added: workspace/max/jpaap/test/goal/metamodel/Order_.java
===================================================================
--- workspace/max/jpaap/test/goal/metamodel/Order_.java (rev 0)
+++ workspace/max/jpaap/test/goal/metamodel/Order_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+package metamodel;
+
+import java.util.Date;
+
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.List;
+import javax.jpa.metamodel.Set;
+import javax.jpa.metamodel.TypesafeMetamodel;
+
+import model.Item;
+import model.Order;
+import model.Shop;
+
+/* @Generated by javac */
+@TypesafeMetamodel
+public abstract class Order_ {
+ public static Attribute<Order, Long> id;
+ public static Set<Order, Item> items;
+ public static Attribute<Order, Boolean> filled;
+ public static Attribute<Order, Date> date;
+ public static List<Order, String> notes;
+ public static Attribute<Order, Shop> shop;
+}
Added: workspace/max/jpaap/test/goal/metamodel/Product_.java
===================================================================
--- workspace/max/jpaap/test/goal/metamodel/Product_.java (rev 0)
+++ workspace/max/jpaap/test/goal/metamodel/Product_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,21 @@
+package metamodel;
+
+import java.math.BigDecimal;
+
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.Set;
+import javax.jpa.metamodel.TypesafeMetamodel;
+
+import model.Item;
+import model.Product;
+import model.Shop;
+
+/* @Generated by javac */
+@TypesafeMetamodel
+public abstract class Product_ {
+ public static Attribute<Product, Long> id;
+ public static Set<Product, Item> items;
+ public static Attribute<Product, String> description;
+ public static Attribute<Product, BigDecimal> price;
+ public static Attribute<Product, Shop> shop;
+}
Added: workspace/max/jpaap/test/goal/metamodel/Shop_.java
===================================================================
--- workspace/max/jpaap/test/goal/metamodel/Shop_.java (rev 0)
+++ workspace/max/jpaap/test/goal/metamodel/Shop_.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,13 @@
+package metamodel;
+
+import javax.jpa.metamodel.Attribute;
+import javax.jpa.metamodel.TypesafeMetamodel;
+
+import model.Shop;
+
+/* @Generated by javac */
+@TypesafeMetamodel
+public abstract class Shop_ {
+ public static Attribute<Shop, Long> id;
+ public static Attribute<Shop, String> name;
+}
Added: workspace/max/jpaap/test/jpa-build.xml
===================================================================
--- workspace/max/jpaap/test/jpa-build.xml (rev 0)
+++ workspace/max/jpaap/test/jpa-build.xml 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project basedir="." default="build" name="jpa-test">
+ <import file="build.xml"/>
+
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <delete dir="build/classes" />
+ <mkdir dir="build/classes"/>
+
+
+ <javac debug="true" debuglevel="${debuglevel}" destdir="build/classes" source="${source}" target="${target}">
+<!-- <compilerarg value="-XprintProcessorInfo" />
+ <compilerarg value="-XprintRounds" /> -->
+
+ <src path="src"/>
+
+ <classpath refid="test.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
+
+
+</project>
Added: workspace/max/jpaap/test/readme.txt
===================================================================
--- workspace/max/jpaap/test/readme.txt (rev 0)
+++ workspace/max/jpaap/test/readme.txt 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,13 @@
+Test project to validate jpaap.
+
+src/ contains code that uses the Criteria API and depends on a metamodel to be generated. Without it there will be compile errors.
+
+jpa-build.xml - Ant file that compiles via javac src/ with jpaap.jar on classpath resulting in generation of metamodel into build/classes
+
+gen-src/ will be created if you enable APT processing in Eclipse
+
+goal/ example of what should be generated
+
+test.jpa-build.xml.launch - Eclipse external tool launch which can be used for quick testing (edit jpaap or test, then launch the build and you get instant feedback/result)
+
+
\ No newline at end of file
Added: workspace/max/jpaap/test/src/Test.java
===================================================================
--- workspace/max/jpaap/test/src/Test.java (rev 0)
+++ workspace/max/jpaap/test/src/Test.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,145 @@
+import static javax.jpa.criteria.JoinType.*;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Set;
+
+import javax.jpa.criteria.Expression;
+import javax.jpa.criteria.Join;
+import javax.jpa.criteria.ListJoin;
+import javax.jpa.criteria.Path;
+import javax.jpa.criteria.Query;
+import javax.jpa.criteria.QueryBuilder;
+import javax.jpa.criteria.Root;
+
+import model.metamodel.Item_;
+import model.metamodel.Order_;
+import model.metamodel.Product_;
+import model.metamodel.Shop_;
+import model.Item;
+import model.Order;
+import model.Product;
+
+/**
+ * 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() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(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.ascending(price), qb.descending(date) );
+ }
+
+ public void testUntypesafe() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(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.ascending(price), qb.descending(date) );
+ }
+
+ /**
+ * Navigation by joining
+ */
+ public void test2() {
+ Query q = qb.create();
+
+ Root<Product> product = q.addRoot(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() {
+ Query q = qb.create();
+
+ Root<Item> item = q.addRoot(Item.class);
+ Join<Item, Order> io = item.join(Item_.namedOrders);
+
+ }
+
+ /**
+ * Navigation by compound Path
+ */
+ public void test3() {
+ Query q = qb.create();
+
+ Root<Item> item = q.addRoot(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() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(Order.class);
+ ListJoin<Order, String> note = order.join(Order_.notes);
+ Expression<Set<Item>> items = order.get(Order_.items);
+ order.fetch(Order_.items, inner);
+
+ q.select(note)
+ .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
+ }
+
+ public void test4Untypesafe() {
+ Query q = qb.create();
+
+ Root<Order> order = q.addRoot(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: workspace/max/jpaap/test/src/model/Item.java
===================================================================
--- workspace/max/jpaap/test/src/model/Item.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Item.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -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;
+
+@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: workspace/max/jpaap/test/src/model/Order.java
===================================================================
--- workspace/max/jpaap/test/src/model/Order.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Order.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,28 @@
+package model;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+@Entity
+public class Order {
+
+ @Id
+ long id;
+
+ @OneToMany
+ Set<Item> items;
+
+ boolean filled;
+ Date date;
+
+ @OneToMany
+ List<String> notes;
+
+ @ManyToOne
+ Shop shop;
+}
Added: workspace/max/jpaap/test/src/model/Product.java
===================================================================
--- workspace/max/jpaap/test/src/model/Product.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Product.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,25 @@
+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;
+
+@Entity
+public class Product {
+
+ @Id
+ long id;
+
+ String description;
+ BigDecimal price;
+
+ @ManyToOne
+ Shop shop;
+
+ @OneToMany
+ Set<Item> items;
+}
Added: workspace/max/jpaap/test/src/model/Shop.java
===================================================================
--- workspace/max/jpaap/test/src/model/Shop.java (rev 0)
+++ workspace/max/jpaap/test/src/model/Shop.java 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,12 @@
+package model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Shop {
+ @Id
+ long id;
+ String name;
+}
+
\ No newline at end of file
Added: workspace/max/jpaap/test/test jpa-build.xml.launch
===================================================================
--- workspace/max/jpaap/test/test jpa-build.xml.launch (rev 0)
+++ workspace/max/jpaap/test/test jpa-build.xml.launch 2009-01-16 16:48:05 UTC (rev 13090)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/test/jpa-build.xml"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="test"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jdk-1.6.0_10"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/test/jpa-build.xml}"/>
+<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
+</launchConfiguration>
15 years, 12 months
JBoss Tools SVN: r13089 - trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-01-16 11:16:06 -0500 (Fri, 16 Jan 2009)
New Revision: 13089
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
Log:
JBIDE-3561 Open-Ons for RichFaces 3.3
RichFaces tags Open-Ons are updated
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-01-16 16:14:10 UTC (rev 13088)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-01-16 16:16:06 UTC (rev 13089)
@@ -37,6 +37,15 @@
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledGroup/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledItem/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopItem/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconInactive/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/saveControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/saveControlIcon/" />
</partitionType>
</contentType>
<contentType id="org.eclipse.wst.html.core.htmlsource">
@@ -66,6 +75,15 @@
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledGroup/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledItem/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopItem/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconInactive/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/saveControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/saveControlIcon/" />
</partitionType>
</contentType>
</hyperlinkPartitioner>
@@ -100,6 +118,15 @@
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledGroup/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledItem/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopItem/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconInactive/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/saveControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/saveControlIcon/" />
</partitionType>
</contentType>
<contentType id="org.eclipse.wst.html.core.htmlsource">
@@ -129,6 +156,15 @@
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledGroup/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopDisabledItem/" />
<axis path="*/[http://richfaces.org/rich]:panelMenu/iconTopItem/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:calendar/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconDisabled/" />
+ <axis path="*/[http://richfaces.org/rich]:comboBox/buttonIconInactive/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceInput/saveControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/cancelControlIcon/" />
+ <axis path="*/[http://richfaces.org/rich]:inplaceSelect/saveControlIcon/" />
</partitionType>
</contentType>
</hyperlinkPartitioner>
15 years, 12 months