[英]org.hibernate.PropertyAccessException: Could not set field value [STRING] value by reflection for String
Does the @Embeddable
for @ManyToMany
relations and additional columns, works with String
? @ManyToMany
关系和附加列的@Embeddable
是否适用于String
? I do not use @Generated Value for @Id
Because my Entity ApplikationUser
我不
@Generated Value for @Id
使用@Generated Value for @Id
因为我的实体ApplikationUser
@Id
@Column(length = 128)
private String applikationUserId;
by business logic has always an Id
按业务逻辑始终有一个
Id
Here my code:这是我的代码:
@EmbeddedId
private ApplikationUserPopupMessageId applikationUserPopupMessageId;
@ManyToOne(fetch = FetchType.EAGER)
@MapsId("applikationUserId")
private ApplikationUser applikationUser;
@ManyToOne(fetch = FetchType.EAGER)
@MapsId("popupMessageId")
private PopupMessage popupMessage;
@Column(name = "gelesen")
private boolean gelesen = false;
@Embeddable
public class ApplikationUserPopupMessageId implements Serializable {
@Column(name = "applikation_user_id")
private String applikationUserId;
@Column(name = "popup_message_id")
private Long popupMessageId;
@Entity
@Table
public class PopupMessage {
@Id
@GeneratedValue
@Column(length = 128)
private Long messageId;
private String title;
private String message;
@OneToMany(
mappedBy = "applikationUser",
cascade = CascadeType.ALL,
orphanRemoval = true
)
private List<ApplikationUserPopupMessage> applikationUserPopupMessages = new ArrayList<>();
@Entity
public class ApplikationUser implements UserDetails {
/**
*
*/
private static final long serialVersionUID = -5517804528054972083L;
@Id
@Column(length = 128)
private String applikationUserId;
@Column
private String password;
@ManyToOne
@JoinColumn(name = "idRole")
private Role role;
private boolean enabled = true;
@OneToMany(
mappedBy = "popupMessage",
cascade = CascadeType.ALL,
orphanRemoval = true
)
private List<ApplikationUserPopupMessage> applikationUserPopupMessages = new ArrayList<>();
EDIT - 23.11.2020 Regards the lack of interest, its seems to be possible to us @Embeddable
with String
?编辑 - 23.11.2020关于缺乏兴趣,我们似乎可以使用
@Embeddable
和String
?
Instantiate applikationUserPopupMessageId:实例化 applikationUserPopupMessageId:
@Entity
public class ApplikationUserPopupMessage {
@EmbeddedId
private ApplikationUserPopupMessageId applikationUserPopupMessageId = new ApplikationUserPopupMessageId();
}
That's known issue这是已知问题
只需在@Embeddable
为相应属性放置 getter 和 setter @Embeddable
。
如果您将访问级别注释为 Field 的实体类是否有帮助
@Entity(access = AccessType.FIELD)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.