我有两个对象 userBO 和 userEntity。我想将对象值从 userEntity 传输到 userBO,并且我要求在传输值时序列化不应该丢失。这就是我正在做的事情。请告诉我这是正确的吗?
public static UserBO converUserEntityToUserBO(UserEntity userEntity) {
UserBO userBO = new UserBO();
userBO.setUserId(userEntity.getUserId());
userBO.setUserFile(userEntity.getUserFile());
userBO.setUserDepartment(userEntity.getUserDepartment());
return userBO;
}
用户BO.class
public class UserBO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3886993061934034729L;
private int userId;
private int departmentId;
private byte[] userFile;
private String dbAction;
//getter and setter
}
用户实体类
@Entity
@Table(name="USER_ENTITY")
public class UserEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4676281792392490908L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="USER_ID")
private int userId;
@Column(name="USER_DEPARTMENT")
private String userDepartment;
@Lob()
@Column(name="USER_FILE")
private byte[] userFile;
//getter and setter
}