From d2a3291f138f88e41d8fed1abcaaa75cd4baf08d Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Wed, 24 Aug 2016 15:46:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4@DistributeTables=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/source/DataDefaultSource.java | 18 ----------- src/org/redkale/source/DistributeTables.java | 31 ------------------- src/org/redkale/source/EntityInfo.java | 4 --- 3 files changed, 53 deletions(-) delete mode 100644 src/org/redkale/source/DistributeTables.java diff --git a/src/org/redkale/source/DataDefaultSource.java b/src/org/redkale/source/DataDefaultSource.java index cce8215ab..309625c82 100644 --- a/src/org/redkale/source/DataDefaultSource.java +++ b/src/org/redkale/source/DataDefaultSource.java @@ -360,24 +360,6 @@ public final class DataDefaultSource implements DataSource, Function infox = loadEntityInfo(t); - stmt = conn.createStatement(); - rs = stmt.executeQuery("SELECT MAX(" + info.getPrimarySQLColumn() + ") FROM " + infox.getTable()); // 必须是同一字段名 - if (rs.next()) { - if (primaryType == int.class) { - int v = rs.getInt(1) / info.allocationSize; - if (v > info.primaryValue.get()) info.primaryValue.set(v); - } else { - long v = rs.getLong(1) / info.allocationSize; - if (v > info.primaryValue.get()) info.primaryValue.set(v); - } - } - rs.close(); - stmt.close(); - } - } info.initedPrimaryValue = true; } } diff --git a/src/org/redkale/source/DistributeTables.java b/src/org/redkale/source/DistributeTables.java deleted file mode 100644 index a304a4bd0..000000000 --- a/src/org/redkale/source/DistributeTables.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.source; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * 当使用DistributeGenerator控制主键值时, 如果表A与表AHistory使用同一主键时, 就需要将表A的class标记: - *
- *  @DistributeTables({AHistory.class})
- *  public class A {
- *  }
- * 
- * 这样DistributeGenerator将从A、B表中取最大值来初始化主键值。 常见场景就是表B是数据表A对应的历史表 - * - *

- * 详情见: http://redkale.org - * - * @author zhangjx - */ -@Target({TYPE}) -@Retention(RUNTIME) -public @interface DistributeTables { - - Class[] value(); -} diff --git a/src/org/redkale/source/EntityInfo.java b/src/org/redkale/source/EntityInfo.java index 7e706b9c0..e76a2629e 100644 --- a/src/org/redkale/source/EntityInfo.java +++ b/src/org/redkale/source/EntityInfo.java @@ -83,8 +83,6 @@ public final class EntityInfo { //---------------------计算主键值---------------------------- private final int nodeid; - final Class[] distributeTables; - final boolean autoGenerated; final boolean distributed; @@ -129,8 +127,6 @@ public final class EntityInfo { this.source = source; //--------------------------------------------- this.nodeid = nodeid >= 0 ? nodeid : 0; - DistributeTables dt = type.getAnnotation(DistributeTables.class); - this.distributeTables = dt == null ? null : dt.value(); LogLevel ll = type.getAnnotation(LogLevel.class); this.logLevel = ll == null ? Integer.MIN_VALUE : Level.parse(ll.value()).intValue();