diff --git a/src/javax/persistence/GeneratedValue.java b/src/javax/persistence/GeneratedValue.java
deleted file mode 100644
index 56056e790..000000000
--- a/src/javax/persistence/GeneratedValue.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/** *****************************************************************************
- * 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 {
-
-}
diff --git a/src/org/redkale/source/DataCallAttribute.java b/src/org/redkale/source/DataCallAttribute.java
index 005edf1fa..371fb85a2 100644
--- a/src/org/redkale/source/DataCallAttribute.java
+++ b/src/org/redkale/source/DataCallAttribute.java
@@ -30,7 +30,6 @@ public class DataCallAttribute implements Attribute {
Class cltmp = clazz;
do {
for (Field field : cltmp.getDeclaredFields()) {
- if (field.getAnnotation(javax.persistence.GeneratedValue.class) == null) continue;
try {
rs = Attribute.create(cltmp, field);
attributes.put(clazz, rs);
diff --git a/src/org/redkale/source/DataJdbcSource.java b/src/org/redkale/source/DataJdbcSource.java
index e27a9e182..629a0209c 100644
--- a/src/org/redkale/source/DataJdbcSource.java
+++ b/src/org/redkale/source/DataJdbcSource.java
@@ -114,21 +114,7 @@ public class DataJdbcSource extends DataSqlSource {
c1 += cc;
}
c = c1;
- }
- if (info.autoGenerated) { //由数据库自动生成主键值
- ResultSet set = prestmt.getGeneratedKeys();
- int i = -1;
- while (set.next()) {
- if (primaryType == int.class) {
- primary.set(entitys[++i], set.getInt(1));
- } else if (primaryType == long.class) {
- primary.set(entitys[++i], set.getLong(1));
- } else {
- primary.set(entitys[++i], set.getObject(1));
- }
- }
- set.close();
- }
+ }
prestmt.close();
//------------------------------------------------------------
if (info.isLoggable(logger, Level.FINEST)) { //打印调试信息
@@ -166,10 +152,9 @@ public class DataJdbcSource extends DataSqlSource {
protected PreparedStatement createInsertPreparedStatement(final Connection conn, final String sql,
final EntityInfo info, T... entitys) throws SQLException {
Attribute[] attrs = info.insertAttributes;
- final PreparedStatement prestmt = info.autoGenerated ? conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS) : conn.prepareStatement(sql);
+ final PreparedStatement prestmt = conn.prepareStatement(sql);
for (final T value : entitys) {
- if (info.autouuid) info.createPrimaryValue(value);
batchStatementParameters(conn, prestmt, info, attrs, value);
prestmt.addBatch();
}
diff --git a/src/org/redkale/source/DataSqlSource.java b/src/org/redkale/source/DataSqlSource.java
index a6080ca5c..a9eec1069 100644
--- a/src/org/redkale/source/DataSqlSource.java
+++ b/src/org/redkale/source/DataSqlSource.java
@@ -316,11 +316,6 @@ public abstract class DataSqlSource extends AbstractService implement
if (entitys.length == 0) return 0;
checkEntity("insert", false, entitys);
final EntityInfo info = loadEntityInfo((Class) entitys[0].getClass());
- if (info.autouuid) {
- for (T value : entitys) {
- info.createPrimaryValue(value);
- }
- }
if (isOnlyCache(info)) return insertCache(info, entitys);
return insertDB(info, entitys).whenComplete((rs, t) -> {
if (t != null) {
@@ -337,11 +332,6 @@ public abstract class DataSqlSource extends AbstractService implement
CompletableFuture future = checkEntity("insert", true, entitys);
if (future != null) return future;
final EntityInfo info = loadEntityInfo((Class) entitys[0].getClass());
- if (info.autouuid) {
- for (T value : entitys) {
- info.createPrimaryValue(value);
- }
- }
if (isOnlyCache(info)) {
return CompletableFuture.supplyAsync(() -> insertCache(info, entitys), getExecutor());
}
diff --git a/src/org/redkale/source/EntityInfo.java b/src/org/redkale/source/EntityInfo.java
index f178c30df..447be4073 100644
--- a/src/org/redkale/source/EntityInfo.java
+++ b/src/org/redkale/source/EntityInfo.java
@@ -154,12 +154,6 @@ public final class EntityInfo {
//Flipper.sort转换成以ORDER BY开头SQL的缓存
private final Map sortOrderbySqls = new ConcurrentHashMap<>();
- //是否由数据库生成主键值
- final boolean autoGenerated;
-
- //是否UUID主键
- final boolean autouuid;
-
//所属的DataSource
final DataSource source;
@@ -287,8 +281,6 @@ public final class EntityInfo {
List> insertattrs = new ArrayList<>();
List updatecols = new ArrayList<>();
List> updateattrs = new ArrayList<>();
- boolean auto = false;
- boolean uuid = false;
Map> cryptCreatorMap = new HashMap<>();
do {
for (Field field : cltmp.getDeclaredFields()) {
@@ -318,19 +310,8 @@ public final class EntityInfo {
}
if (field.getAnnotation(javax.persistence.Id.class) != null && idAttr0 == null) {
idAttr0 = attr;
- GeneratedValue gv = field.getAnnotation(GeneratedValue.class);
- auto = gv != null;
-// if (gv != null && gv.strategy() != GenerationType.IDENTITY) {
-// throw new RuntimeException(cltmp.getName() + "'s @ID primary not a GenerationType.IDENTITY");
-// }
- if (gv != null && field.getType() == String.class) { //UUID
- uuid = true;
- auto = false;
- }
- if (!auto) {
- insertcols.add(sqlfield);
- insertattrs.add(attr);
- }
+ insertcols.add(sqlfield);
+ insertattrs.add(attr);
} else {
if (col == null || col.insertable()) {
insertcols.add(sqlfield);
@@ -456,8 +437,6 @@ public final class EntityInfo {
this.deleteNamesPrepareSQL = null;
this.queryNamesPrepareSQL = null;
}
- this.autoGenerated = auto;
- this.autouuid = uuid;
//----------------cache--------------
Cacheable c = type.getAnnotation(Cacheable.class);
if (this.table == null || (!cacheForbidden && c != null && c.value())) {
@@ -482,15 +461,6 @@ public final class EntityInfo {
return jsonConvert;
}
- /**
- * 创建主键值,目前只支持UUID赋值
- *
- * @param src Entity对象
- */
- public void createPrimaryValue(T src) {
- if (autouuid) getPrimary().set(src, Utility.uuid());
- }
-
/**
* 获取Entity缓存器
*
@@ -536,14 +506,6 @@ public final class EntityInfo {
return table == null;
}
- public boolean isAutoGenerated() {
- return autoGenerated;
- }
-
- public boolean isAutouuid() {
- return autouuid;
- }
-
public DistributeTableStrategy getTableStrategy() {
return tableStrategy;
}