我有一个大问题,我们正在努力在项目中实施单曲。我们的管理员在DB(FEDERATED
)中创建了一些表mysql
,因为这个应用程序抛出了很多异常。如何在JPA
中将ManyToOne
关联的字段映射到该联合表?它在更新时抛出异常,并在列LOCALITY_ID
的表用户中插入(它必须只有id)。
错误:
javax.persistence.PersistenceException:org.hibernate.PropertyValueException:not-null属性引用null或transient值:...... stuff
public class User extends BaseEntity implements IAccessDataAware, UserDetails, IAuditable {
/** serial version */
private static final long serialVersionUID = 2899839338023778586L;
@Embedded
private AccessData accessData = new AccessData();
@Column(name = "FIRST_NAME", length = Constants.COLUMN_NORMAL_LENGTH, nullable = false)
private String firstName;
@Column(name = "LAST_NAME", length = Constants.COLUMN_NORMAL_LENGTH, nullable = false)
private String lastName;
@Column(name = "CNP", length = Constants.COLUMN_CNP_LENGTH, nullable = true)
private String cnp;
@Column(name = "EMAIL", length = Constants.COLUMN_NORMAL_LENGTH, nullable = false)
private String email;
@Column(name = "PHONE", length = Constants.COLUMN_NORMAL_LENGTH)
private String phone;
@Column(name = "USERNAME", length = Constants.COLUMN_NORMAL_LENGTH, nullable = false)
private String userName;
@Column(name = "PASSWORD", length = Constants.COLUMN_MD5_ENCRYPTED_LENGTH, nullable = false)
private String password;
@Column(name = "PASSWORD_OAUTH", length = Constants.COLUMN_ENCRYPTED_LENGTH, nullable = true)
private String passwordOAuth;
@Column(name = "SALT_OAUTH", length = Constants.COLUMN_ENCRYPTED_LENGTH, nullable = true)
private String salt;
@Column(name = "PASSWORD_OAUTH_ALGORITHM", length = Constants.COLUMN_ENCRYPTED_LENGTH, nullable = true)
private String passwordOAuthAlgorithm;
@Column(name="digital_signature")
private Boolean digitalSignature=Boolean.FALSE;
@Column(name = "DESCRIPTION", length = Constants.COLUMN_DESCRIPTION_LENGTH)
private String description;
@Column(name = "PATH_AVATAR_IMAGE", length = Constants.COLUMN_NORMAL_LENGTH)
private String pathAvatarImage;
@Column(name = "PATH_AVATAR_IMAGE_ORIGINAL", length = Constants.COLUMN_NORMAL_LENGTH)
private String pathAvatarImageOriginal;
@ManyToOne(optional = false)
@JoinColumn(name = "ROLE_ID")
private Role role;
@OneToMany(mappedBy = "user")
private List<HistoryEvent> historyEvents;
@ManyToOne(cascade = {CascadeType.ALL})
@JoinColumn(name = "LOCALITY_ID")
private Locality locality;
....... Getters and Setters
}
谢谢