如何删除 Ebean ORM 实体 属性
How remove Ebean ORM Entity property
在 java 模型实体中有以下 属性
@Entity
@Table(name = "device_key")
public class UserKey implements Serializable {
private long id;
@Column(name = "device_id")
private int deviceId;
@Column(name = "device_hub_id")
private int serverId;
private byte status;
@Column(name = "user_id")
private int peopleSeq; //人员序号
private short tempSeq; //临时证
@Column(name = "from_date")
private String startDate;
@Column(name = "to_date")
private String endDate;
@Column(name = "from_time")
private String startTime;
@Column(name = "to_time")
private String endTime;
private String peopleName;
private short attr;
}
但是在数据库中table只有属性
的一部分
CREATE TABLE `device_key` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`device_id` bigint(20) DEFAULT NULL,
`user_id` bigint(20) DEFAULT NULL,
`device_hub_id` bigint(20) DEFAULT NULL,
`from_date` date DEFAULT NULL,
`to_date` date DEFAULT NULL,
`from_time` time DEFAULT NULL,
`to_time` time DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`last_time` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_key_device` (`device_id`),
CONSTRAINT `FK_key_device` FOREIGN KEY (`device_id`) REFERENCES `device` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4;
我想知道在ebean中如何删除一些属性使用注解
添加@Transient
注释
Transient Fields Transient entity fields are fields that do not participate in persistence and their values are never stored in the
database (similar to transient fields in Java that do not participate
in serialization). Static and final entity fields are always
considered to be transient. Other fields can be declared explicitly as
transient using either the Java transient modifier (which also affects
serialization) or the JPA @Transient annotation (which only affects
persistence):
@Entity
public class EntityWithTransientFields {
static int transient1; // not persistent because of static
final int transient2 = 0; // not persistent because of final
transient int transient3; // not persistent because of transient
@Transient int transient4; // not persistent because of @Transient
}
The above entity class contains only transient (non persistent) entity
fields with no real content to be stored in the database.
在 java 模型实体中有以下 属性
@Entity
@Table(name = "device_key")
public class UserKey implements Serializable {
private long id;
@Column(name = "device_id")
private int deviceId;
@Column(name = "device_hub_id")
private int serverId;
private byte status;
@Column(name = "user_id")
private int peopleSeq; //人员序号
private short tempSeq; //临时证
@Column(name = "from_date")
private String startDate;
@Column(name = "to_date")
private String endDate;
@Column(name = "from_time")
private String startTime;
@Column(name = "to_time")
private String endTime;
private String peopleName;
private short attr;
}
但是在数据库中table只有属性
的一部分CREATE TABLE `device_key` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`device_id` bigint(20) DEFAULT NULL,
`user_id` bigint(20) DEFAULT NULL,
`device_hub_id` bigint(20) DEFAULT NULL,
`from_date` date DEFAULT NULL,
`to_date` date DEFAULT NULL,
`from_time` time DEFAULT NULL,
`to_time` time DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`last_time` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_key_device` (`device_id`),
CONSTRAINT `FK_key_device` FOREIGN KEY (`device_id`) REFERENCES `device` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4;
我想知道在ebean中如何删除一些属性使用注解
添加@Transient
注释
Transient Fields Transient entity fields are fields that do not participate in persistence and their values are never stored in the database (similar to transient fields in Java that do not participate in serialization). Static and final entity fields are always considered to be transient. Other fields can be declared explicitly as transient using either the Java transient modifier (which also affects serialization) or the JPA @Transient annotation (which only affects persistence):
@Entity public class EntityWithTransientFields { static int transient1; // not persistent because of static final int transient2 = 0; // not persistent because of final transient int transient3; // not persistent because of transient @Transient int transient4; // not persistent because of @Transient }
The above entity class contains only transient (non persistent) entity fields with no real content to be stored in the database.