- hibernate 忽略映射字段 @Transient
import org.springframework.data.annotation.Transient;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "t_student")
public class Student {
@Id
@GeneratedValue
private Long id;
@Transient
private String password;
private Integer age;
@Transient
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
- mybatis-plus忽略映射字段 @TableField(exist = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@TableName("ls_emp_info")
public class EmpInfo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@TableId(value = "c_id")
private Integer cid;
@Column(name = "c_name")
@TableField(value = "c_name")
private String cameraName;
@Column(name = "c_brand")
@TableField(value = "c_brand")
private String cameraBrand;
@ManyToMany
@JoinTable(
name = "Camera_User",
joinColumns = @JoinColumn(name = "cid"),
inverseJoinColumns = @JoinColumn(name = "uid")
)
@TableField(exist = false)
private List<User> cameraUser;
@TableField(exist = false)
private String postMutex;
@TableField(exist = true)
private String postName;
}