This commit is contained in:
@@ -471,7 +471,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (final T value : values) {
|
for (final T value : values) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (info.distributed) info.createPrimaryValue(value);
|
if (info.distributed || info.autoUUID) info.createPrimaryValue(value);
|
||||||
for (Attribute<T, Serializable> attr : attrs) {
|
for (Attribute<T, Serializable> attr : attrs) {
|
||||||
Object a = attr.get(value);
|
Object a = attr.get(value);
|
||||||
ps[i] = FilterNode.formatToString(a);
|
ps[i] = FilterNode.formatToString(a);
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ public final class EntityInfo<T> {
|
|||||||
|
|
||||||
final boolean autoGenerated;
|
final boolean autoGenerated;
|
||||||
|
|
||||||
|
final boolean autoUUID;
|
||||||
|
|
||||||
final boolean distributed;
|
final boolean distributed;
|
||||||
|
|
||||||
boolean initedPrimaryValue = false;
|
boolean initedPrimaryValue = false;
|
||||||
@@ -173,6 +175,7 @@ public final class EntityInfo<T> {
|
|||||||
List<String> updatecols = new ArrayList<>();
|
List<String> updatecols = new ArrayList<>();
|
||||||
List<Attribute<T, Serializable>> updateattrs = new ArrayList<>();
|
List<Attribute<T, Serializable>> updateattrs = new ArrayList<>();
|
||||||
boolean auto = false;
|
boolean auto = false;
|
||||||
|
boolean uuid = false;
|
||||||
boolean sqldistribute = false;
|
boolean sqldistribute = false;
|
||||||
int allocationSize0 = 0;
|
int allocationSize0 = 0;
|
||||||
|
|
||||||
@@ -213,6 +216,11 @@ public final class EntityInfo<T> {
|
|||||||
allocationSize0 = dg.allocationSize();
|
allocationSize0 = dg.allocationSize();
|
||||||
primaryValue.set(dg.initialValue());
|
primaryValue.set(dg.initialValue());
|
||||||
}
|
}
|
||||||
|
if (gv != null && field.getType() == String.class) { //UUID
|
||||||
|
uuid = true;
|
||||||
|
auto = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!auto) {
|
if (!auto) {
|
||||||
insertcols.add(sqlfield);
|
insertcols.add(sqlfield);
|
||||||
insertattrs.add(attr);
|
insertattrs.add(attr);
|
||||||
@@ -264,6 +272,7 @@ public final class EntityInfo<T> {
|
|||||||
this.querySQL = null;
|
this.querySQL = null;
|
||||||
}
|
}
|
||||||
this.autoGenerated = auto;
|
this.autoGenerated = auto;
|
||||||
|
this.autoUUID = uuid;
|
||||||
this.distributed = sqldistribute;
|
this.distributed = sqldistribute;
|
||||||
this.allocationSize = allocationSize0;
|
this.allocationSize = allocationSize0;
|
||||||
//----------------cache--------------
|
//----------------cache--------------
|
||||||
@@ -282,6 +291,10 @@ public final class EntityInfo<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createPrimaryValue(T src) {
|
public void createPrimaryValue(T src) {
|
||||||
|
if (autoUUID) {
|
||||||
|
getPrimary().set(src, Utility.uuid());
|
||||||
|
return;
|
||||||
|
}
|
||||||
long v = allocationSize > 1 ? (primaryValue.incrementAndGet() * allocationSize + nodeid) : primaryValue.incrementAndGet();
|
long v = allocationSize > 1 ? (primaryValue.incrementAndGet() * allocationSize + nodeid) : primaryValue.incrementAndGet();
|
||||||
if (primary.type() == int.class || primary.type() == Integer.class) {
|
if (primary.type() == int.class || primary.type() == Integer.class) {
|
||||||
getPrimary().set(src, (Integer) ((Long) v).intValue());
|
getPrimary().set(src, (Integer) ((Long) v).intValue());
|
||||||
|
|||||||
Reference in New Issue
Block a user