删除@DistributeTables功能
This commit is contained in:
@@ -360,24 +360,6 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
if (info.distributeTables != null) { //是否还有其他表
|
|
||||||
for (final Class t : info.distributeTables) {
|
|
||||||
EntityInfo<T> 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;
|
info.initedPrimaryValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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标记:
|
|
||||||
* <blockquote><pre>
|
|
||||||
* @DistributeTables({AHistory.class})
|
|
||||||
* public class A {
|
|
||||||
* }
|
|
||||||
* </pre></blockquote>
|
|
||||||
* 这样DistributeGenerator将从A、B表中取最大值来初始化主键值。 常见场景就是表B是数据表A对应的历史表
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* 详情见: http://redkale.org
|
|
||||||
*
|
|
||||||
* @author zhangjx
|
|
||||||
*/
|
|
||||||
@Target({TYPE})
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface DistributeTables {
|
|
||||||
|
|
||||||
Class[] value();
|
|
||||||
}
|
|
||||||
@@ -83,8 +83,6 @@ public final class EntityInfo<T> {
|
|||||||
//---------------------计算主键值----------------------------
|
//---------------------计算主键值----------------------------
|
||||||
private final int nodeid;
|
private final int nodeid;
|
||||||
|
|
||||||
final Class[] distributeTables;
|
|
||||||
|
|
||||||
final boolean autoGenerated;
|
final boolean autoGenerated;
|
||||||
|
|
||||||
final boolean distributed;
|
final boolean distributed;
|
||||||
@@ -129,8 +127,6 @@ public final class EntityInfo<T> {
|
|||||||
this.source = source;
|
this.source = source;
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
this.nodeid = nodeid >= 0 ? nodeid : 0;
|
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);
|
LogLevel ll = type.getAnnotation(LogLevel.class);
|
||||||
this.logLevel = ll == null ? Integer.MIN_VALUE : Level.parse(ll.value()).intValue();
|
this.logLevel = ll == null ? Integer.MIN_VALUE : Level.parse(ll.value()).intValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user