Hibernate を使用してエンティティのアクセス許可を保持するのに問題があります。属性 Group (Foreign key) を持つ多くの Permission オブジェクトを保存する必要がありますが、同時に Permission を保存していて、Group を保存しているため、設定する Group ID (主キー) がありません。関連付けを行う権限オブジェクト。
私の関係:
@Entity
@BatchSize(size = 10)
public class Group implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "grupo")
@JsonIgnore
private List<Permissao> permissoes;
}
@Entity
@BatchSize(size = 10)
public class Permission implements Serializable {
@ManyToOne
private Grupo grupo;
}
スタック:
SEVERE: Servlet.service() for servlet [hemisphere-web] in context with path
[/hemisphere-web] threw exception [Request processing failed; nested exception is
org.springframework.dao.InvalidDataAccessApiUsageException:
org.hibernate.TransientPropertyValueException: object references an unsaved transient
instance - save the transient instance before flushing:
net.pontoall.hemisphere.core.model.Permission.grupo ->
net.pontoall.hemisphere.core.model.Grupo; nested exception is
java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object
references an unsaved transient instance - save the transient instance before flushing:
net.pontoall.hemisphere.core.model.Permissao.grupo ->
net.pontoall.hemisphere.core.model.Grupo] with root cause
org.hibernate.TransientPropertyValueException: object references an unsaved transient
instance - save the transient instance before flushing:
net.pontoall.hemisphere.core.model.Permissao.grupo -> net.pontoall.hemisphere.core.model.Grupo
誰かヒントをくれませんか?