mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fix modified_time null value error (#2157)
* template config load * compile vue frontend for product * fix modified_time null value error * modify
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.alibaba.otter.canal.admin.model;
|
package com.alibaba.otter.canal.admin.model;
|
||||||
|
|
||||||
import io.ebean.Finder;
|
import io.ebean.Finder;
|
||||||
|
import io.ebean.annotation.WhenModified;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@@ -34,6 +35,7 @@ public class CanalCluster extends Model {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private String zkHosts;
|
private String zkHosts;
|
||||||
|
@WhenModified
|
||||||
private Date modifiedTime;
|
private Date modifiedTime;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.alibaba.otter.canal.admin.model;
|
package com.alibaba.otter.canal.admin.model;
|
||||||
|
|
||||||
import io.ebean.Finder;
|
import io.ebean.Finder;
|
||||||
|
import io.ebean.annotation.WhenModified;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ public class CanalConfig extends Model {
|
|||||||
private String content;
|
private String content;
|
||||||
private String contentMd5;
|
private String contentMd5;
|
||||||
private String status;
|
private String status;
|
||||||
|
@WhenModified
|
||||||
private Date modifiedTime;
|
private Date modifiedTime;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Date;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
import io.ebean.Finder;
|
import io.ebean.Finder;
|
||||||
|
import io.ebean.annotation.WhenModified;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Canal实例配置信息实体类
|
* Canal实例配置信息实体类
|
||||||
@@ -44,6 +45,7 @@ public class CanalInstanceConfig extends Model {
|
|||||||
private String content;
|
private String content;
|
||||||
private String contentMd5;
|
private String contentMd5;
|
||||||
private String status; // 1: 正常 0: 停止
|
private String status; // 1: 正常 0: 停止
|
||||||
|
@WhenModified
|
||||||
private Date modifiedTime;
|
private Date modifiedTime;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package com.alibaba.otter.canal.admin.model;
|
package com.alibaba.otter.canal.admin.model;
|
||||||
|
|
||||||
import io.ebean.Ebean;
|
|
||||||
import io.ebean.EbeanServer;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.OptimisticLockException;
|
import javax.persistence.OptimisticLockException;
|
||||||
|
|
||||||
import org.apache.commons.beanutils.PropertyUtils;
|
import org.apache.commons.beanutils.PropertyUtils;
|
||||||
|
|
||||||
|
import io.ebean.Ebean;
|
||||||
|
import io.ebean.EbeanServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EBean Model扩展类
|
* EBean Model扩展类
|
||||||
*
|
*
|
||||||
@@ -35,21 +32,10 @@ public abstract class Model extends io.ebean.Model {
|
|||||||
|
|
||||||
public void saveOrUpdate() {
|
public void saveOrUpdate() {
|
||||||
try {
|
try {
|
||||||
Field idField = null;
|
EbeanServer ebeanServer = Ebean.getDefaultServer();
|
||||||
// find id field
|
Object id = ebeanServer.getBeanId(this);
|
||||||
Field[] fields = this.getClass().getDeclaredFields();
|
if (id == null) {
|
||||||
for (Field field : fields) {
|
init();
|
||||||
Id idAnn = field.getAnnotation(Id.class);
|
|
||||||
if (idAnn != null) {
|
|
||||||
idField = field;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (idField == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Object idVal = PropertyUtils.getProperty(this, idField.getName());
|
|
||||||
if (idVal == null) {
|
|
||||||
this.save();
|
this.save();
|
||||||
} else {
|
} else {
|
||||||
this.update();
|
this.update();
|
||||||
@@ -63,7 +49,13 @@ public abstract class Model extends io.ebean.Model {
|
|||||||
try {
|
try {
|
||||||
EbeanServer ebeanServer = Ebean.getDefaultServer();
|
EbeanServer ebeanServer = Ebean.getDefaultServer();
|
||||||
Object id = ebeanServer.getBeanId(this);
|
Object id = ebeanServer.getBeanId(this);
|
||||||
|
if (id == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Object model = ebeanServer.createQuery(this.getClass()).where().idEq(id).findOne();
|
Object model = ebeanServer.createQuery(this.getClass()).where().idEq(id).findOne();
|
||||||
|
if (model == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (String propertyName : propertiesNames) {
|
for (String propertyName : propertiesNames) {
|
||||||
if (propertyName.startsWith("nn:")) { // not null
|
if (propertyName.startsWith("nn:")) { // not null
|
||||||
propertyName = propertyName.substring(3);
|
propertyName = propertyName.substring(3);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.alibaba.otter.canal.admin.model;
|
package com.alibaba.otter.canal.admin.model;
|
||||||
|
|
||||||
import io.ebean.Finder;
|
import io.ebean.Finder;
|
||||||
|
import io.ebean.annotation.WhenModified;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ public class NodeServer extends Model {
|
|||||||
private Integer metricPort;
|
private Integer metricPort;
|
||||||
private Integer tcpPort;
|
private Integer tcpPort;
|
||||||
private String status;
|
private String status;
|
||||||
|
@WhenModified
|
||||||
private Date modifiedTime;
|
private Date modifiedTime;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.alibaba.otter.canal.admin.model;
|
package com.alibaba.otter.canal.admin.model;
|
||||||
|
|
||||||
import io.ebean.Finder;
|
import io.ebean.Finder;
|
||||||
|
import io.ebean.annotation.WhenCreated;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@@ -36,6 +37,7 @@ public class User extends Model {
|
|||||||
private String introduction;
|
private String introduction;
|
||||||
private String avatar;
|
private String avatar;
|
||||||
private String name;
|
private String name;
|
||||||
|
@WhenCreated
|
||||||
private Date creationDate;
|
private Date creationDate;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
|
|||||||
Reference in New Issue
Block a user