You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
package db.model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
import org.springframework.dao.DataAccessException;
|
|
|
|
import java.io.Serializable;
|
|
|
|
/**
|
|
* Created by reborn on 2017/8/3.
|
|
*/
|
|
|
|
public abstract class AbstractModel {
|
|
protected Logger log=LogManager.getLogger();
|
|
|
|
public abstract Serializable primaryKey();
|
|
|
|
public abstract String tableNote();
|
|
|
|
private DataAccessException dataAccessException;
|
|
|
|
private static ObjectMapper objectMapper=new ObjectMapper();
|
|
|
|
static {
|
|
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
|
}
|
|
|
|
private Serializable[] checkeds;
|
|
|
|
private DetachedCriteria criteria;
|
|
|
|
public Serializable[] getCheckeds() {
|
|
return checkeds;
|
|
}
|
|
|
|
public void setCheckeds(Serializable[] checkeds) {
|
|
this.checkeds = checkeds;
|
|
}
|
|
|
|
public DataAccessException getDataAccessException() {
|
|
return dataAccessException;
|
|
}
|
|
|
|
public void setDataAccessException(DataAccessException dataAccessException) {
|
|
this.dataAccessException = dataAccessException;
|
|
}
|
|
|
|
public DetachedCriteria getCriteria() {
|
|
return criteria;
|
|
}
|
|
|
|
public void setCriteria(DetachedCriteria criteria) {
|
|
this.criteria = criteria;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
try {
|
|
return objectMapper.writeValueAsString(this);
|
|
} catch (JsonProcessingException e) {
|
|
log.info(e);
|
|
return super.toString();
|
|
}
|
|
}
|
|
}
|
|
|