From 17d0ab1fe52986bfdfa830f55604a28ad3abfabd Mon Sep 17 00:00:00 2001
From: RedKale <22250530@qq.com>
Date: Thu, 31 Mar 2016 17:59:24 +0800
Subject: [PATCH]
---
src/META-INF/application-template.xml | 188 ++++++++++++++++++++++
src/META-INF/logging-template.properties | 21 +++
src/javax/persistence/Cacheable.java | 45 ++++++
src/javax/persistence/Column.java | 143 ++++++++++++++++
src/javax/persistence/Entity.java | 43 +++++
src/javax/persistence/GeneratedValue.java | 79 +++++++++
src/javax/persistence/GenerationType.java | 56 +++++++
src/javax/persistence/Id.java | 55 +++++++
src/javax/persistence/Table.java | 63 ++++++++
src/javax/persistence/Transient.java | 45 ++++++
10 files changed, 738 insertions(+)
create mode 100644 src/META-INF/application-template.xml
create mode 100644 src/META-INF/logging-template.properties
create mode 100644 src/javax/persistence/Cacheable.java
create mode 100644 src/javax/persistence/Column.java
create mode 100644 src/javax/persistence/Entity.java
create mode 100644 src/javax/persistence/GeneratedValue.java
create mode 100644 src/javax/persistence/GenerationType.java
create mode 100644 src/javax/persistence/Id.java
create mode 100644 src/javax/persistence/Table.java
create mode 100644 src/javax/persistence/Transient.java
diff --git a/src/META-INF/application-template.xml b/src/META-INF/application-template.xml
new file mode 100644
index 000000000..8ccaeae47
--- /dev/null
+++ b/src/META-INF/application-template.xml
@@ -0,0 +1,188 @@
+
+
+
+persistence.xml caching element
+ * is ENABLE_SELECTIVE or DISABLE_SELECTIVE.
+ * The value of the Cacheable annotation is inherited by
+ * subclasses; it can be overridden by specifying
+ * Cacheable on a subclass.
+ *
+ *
Cacheable(false) means that the entity and its state must
+ * not be cached by the provider.
+ *
+ * @since Java Persistence 2.0
+ */
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface Cacheable {
+
+ /**
+ * (Optional) Whether or not the entity should be cached.
+ * @return boolean
+ */
+ boolean value() default true;
+}
diff --git a/src/javax/persistence/Column.java b/src/javax/persistence/Column.java
new file mode 100644
index 000000000..a4f6e1dc3
--- /dev/null
+++ b/src/javax/persistence/Column.java
@@ -0,0 +1,143 @@
+/** *****************************************************************************
+ * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Linda DeMichiel - Java Persistence 2.1
+ * Linda DeMichiel - Java Persistence 2.0
+ *
+ ***************************************************************************** */
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Specifies the mapped column for a persistent property or field.
+ * If no Column annotation is specified, the default values apply.
+ *
+ *
+ * Example 1:
+ *
+ * @Column(name="DESC", nullable=false, length=512)
+ * public String getDescription() { return description; }
+ *
+ * Example 2:
+ *
+ * @Column(name="DESC",
+ * columnDefinition="CLOB NOT NULL",
+ * table="EMP_DETAIL")
+ * @Lob
+ * public String getDescription() { return description; }
+ *
+ * Example 3:
+ *
+ * @Column(name="ORDER_COST", updatable=false, precision=12, scale=2)
+ * public BigDecimal getCost() { return cost; }
+ *
+ *
+ *
+ *
+ * @since Java Persistence 1.0
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Column {
+
+ /**
+ * (Optional) The name of the column. Defaults to
+ * the property or field name.
+ *
+ * @return String
+ */
+ String name() default "";
+
+ /**
+ * (Optional) Whether the column 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
+ * corresponds to only a single column. This constraint applies
+ * in addition to any constraint entailed by primary key mapping and
+ * to constraints specified at the table level.
+ *
+ * @return boolean
+ */
+ boolean unique() default false;
+
+ /**
+ * (Optional) Whether the database column is nullable.
+ *
+ * @return boolean
+ */
+ boolean nullable() default true;
+
+ /**
+ * (Optional) Whether the column is included in SQL INSERT
+ * statements generated by the persistence provider.
+ *
+ * @return boolean
+ */
+ boolean insertable() default true;
+
+ /**
+ * (Optional) Whether the column is included in SQL UPDATE
+ * statements generated by the persistence provider.
+ *
+ * @return boolean
+ */
+ boolean updatable() default true;
+
+ /**
+ * (Optional) 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. + * + * @return String + */ + String columnDefinition() default ""; + + /** + * (Optional) The name of the table that contains the column. + * If absent the column is assumed to be in the primary table. + * + * @return String + */ + String table() default ""; + + /** + * (Optional) The column length. (Applies only if a + * string-valued column is used.) + * + * @return int + */ + int length() default 255; + + /** + * (Optional) 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. + * + * @return int + */ + int precision() default 0; + + /** + * (Optional) The scale for a decimal (exact numeric) column. + * (Applies only if a decimal column is used.) + * + * @return int + */ + int scale() default 0; +} diff --git a/src/javax/persistence/Entity.java b/src/javax/persistence/Entity.java new file mode 100644 index 000000000..024df1bb5 --- /dev/null +++ b/src/javax/persistence/Entity.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Linda DeMichiel - Java Persistence 2.1 + * Linda DeMichiel - Java Persistence 2.0 + * + ******************************************************************************/ +package javax.persistence; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.Documented; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Specifies that the class is an entity. This annotation is applied to the + * entity class. + * + * @since Java Persistence 1.0 + */ +@Documented +@Target(TYPE) +@Retention(RUNTIME) +public @interface Entity { + + /** + * (Optional) The entity name. 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. + * @return String + */ + String name() default ""; +} diff --git a/src/javax/persistence/GeneratedValue.java b/src/javax/persistence/GeneratedValue.java new file mode 100644 index 000000000..0d66f074a --- /dev/null +++ b/src/javax/persistence/GeneratedValue.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Linda DeMichiel - Java Persistence 2.1 + * Linda DeMichiel - Java Persistence 2.0 + * + ******************************************************************************/ +package javax.persistence; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * 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 {@link Id} annotation.
+ * The use of the GeneratedValue annotation is only
+ * required to be supported for simple primary keys. Use of the
+ * GeneratedValue annotation is not supported for derived
+ * primary keys.
+ *
+ *
+ *
+ * Example 1:
+ *
+ * @Id
+ * @GeneratedValue(strategy=SEQUENCE, generator="CUST_SEQ")
+ * @Column(name="CUST_ID")
+ * public Long getId() { return id; }
+ *
+ * Example 2:
+ *
+ * @Id
+ * @GeneratedValue(strategy=TABLE, generator="CUST_GEN")
+ * @Column(name="CUST_ID")
+ * Long id;
+ *
+ *
+ * @see Id
+ *
+ * @since Java Persistence 1.0
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+
+public @interface GeneratedValue {
+ /**
+ * (Optional) The primary key generation strategy
+ * that the persistence provider must use to
+ * generate the annotated entity primary key.
+ * @return GenerationType
+ */
+ @Deprecated
+ GenerationType strategy() default GenerationType.AUTO;
+
+ /**
+ * (Optional) 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.
+ * @return String
+ */
+ @Deprecated
+ String generator() default "";
+}
diff --git a/src/javax/persistence/GenerationType.java b/src/javax/persistence/GenerationType.java
new file mode 100644
index 000000000..9d1980e83
--- /dev/null
+++ b/src/javax/persistence/GenerationType.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Linda DeMichiel - Java Persistence 2.1
+ * Linda DeMichiel - Java Persistence 2.0
+ *
+ ******************************************************************************/
+package javax.persistence;
+
+/**
+ * Defines the types of primary key generation strategies.
+ *
+ * @see GeneratedValue
+ *
+ * @since Java Persistence 1.0
+ */
+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 a database sequence.
+ */
+ SEQUENCE,
+
+ /**
+ * Indicates that the persistence provider must assign
+ * primary keys for the entity using a 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
+}
diff --git a/src/javax/persistence/Id.java b/src/javax/persistence/Id.java
new file mode 100644
index 000000000..a201843be
--- /dev/null
+++ b/src/javax/persistence/Id.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Linda DeMichiel - Java Persistence 2.1
+ * Linda DeMichiel - Java Persistence 2.0
+ *
+ ******************************************************************************/
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Specifies the primary key of an entity.
+ * The field or property to which the Id annotation is applied
+ * should be one of the following types: any Java primitive type;
+ * any primitive wrapper type;
+ * String;
+ * java.util.Date;
+ * java.sql.Date;
+ * java.math.BigDecimal;
+ * java.math.BigInteger.
+ *
+ *
The mapped column for the primary key of the entity is assumed
+ * to be the primary key of the primary table. If no Column annotation
+ * is specified, the primary key column name is assumed to be the name
+ * of the primary key property or field.
+ *
+ *
+ * Example:
+ *
+ * @Id
+ * public Long getId() { return id; }
+ *
+ *
+ * @see Column
+ * @see GeneratedValue
+ *
+ * @since Java Persistence 1.0
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+
+public @interface Id {}
diff --git a/src/javax/persistence/Table.java b/src/javax/persistence/Table.java
new file mode 100644
index 000000000..dd39e3784
--- /dev/null
+++ b/src/javax/persistence/Table.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Linda DeMichiel - Java Persistence 2.1
+ * Linda DeMichiel - Java Persistence 2.0
+ *
+ ******************************************************************************/
+package javax.persistence;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * 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.
+ *
+ *
+ * Example:
+ *
+ * @Entity
+ * @Table(name="CUST", schema="RECORDS")
+ * public class Customer { ... }
+ *
+ *
+ * @since Java Persistence 1.0
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface Table {
+
+ /**
+ * (Optional) The name of the table.
+ * Defaults to the entity name. + * @return String + */ + String name() default ""; + + /** (Optional) The catalog of the table. + *
Defaults to the default catalog. + * @return String + */ + String catalog() default ""; + + /** (Optional) The schema of the table. + *
Defaults to the default schema for user. + * @return String + */ + String schema() default ""; + +} diff --git a/src/javax/persistence/Transient.java b/src/javax/persistence/Transient.java new file mode 100644 index 000000000..81446afd7 --- /dev/null +++ b/src/javax/persistence/Transient.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Linda DeMichiel - Java Persistence 2.1 + * Linda DeMichiel - Java Persistence 2.0 + * + ******************************************************************************/ +package javax.persistence; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * 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. + * + *
+ * Example:
+ *
+ * @Entity
+ * public class Employee {
+ * @Id int id;
+ * @Transient User currentUser;
+ * ...
+ * }
+ *
+ *
+ * @since Java Persistence 1.0
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+
+public @interface Transient {}