Я застрял в этой ошибке.
это моя схема базы данных, которую я хочу реализовать.
, поэтому ясделал History, HistoryAuth, HistoryAuthType, HistoryTag и HistoryRepository для операции CRUD.
History.java
package com.wrapsody.demo;
import lombok.*;
import javax.persistence.*; import java.util.ArrayList; import java.util.List;
@NoArgsConstructor(access = AccessLevel.PROTECTED) @Data @Entity public class History {
@Id
@GeneratedValue
private Long historyId;
@Column
private String historyMasterName;
@Column
private String historyFreeSetName;
@OneToMany
@JoinColumn
private List<HistoryTag> tags = new ArrayList<HistoryTag>();
@OneToMany
@JoinColumn
private List<HistoryAuth> auths = new ArrayList<HistoryAuth>();
@Builder
History(String historyMasterName, String historyFreeSetName) {
this.historyMasterName = historyMasterName;
this.historyFreeSetName = historyFreeSetName;
} }
HistoryAuth.java
package com.wrapsody.demo;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
public class HistoryAuth {
@Id
@GeneratedValue
private Long historyAuthId;
@Column
private String historyAuthName;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(insertable = false, updatable = false)
private HistoryAuthType historyAuthType;
@Builder
HistoryAuth(String historyAuthName, HistoryAuthType historyAuthType) {
this.historyAuthName = historyAuthName;
this.historyAuthType = historyAuthType;
}
}
HistoryAuthType.java
package com.wrapsody.demo;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
public class HistoryAuthType {
@Id
@GeneratedValue
private Long historyAuthTypeId;
@Column
private String historyAuthTypeName;
@Builder
HistoryAuthType(String historyAuthTypeName) {
this.historyAuthTypeName = historyAuthTypeName;
}
}
HistoryTag.java
package com.wrapsody.demo;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
public class HistoryTag {
@Id
@GeneratedValue
private Long historyTagId;
@Column
private String historyTagName;
@Builder
HistoryTag(String historyTagName) {
this.historyTagName = historyTagName;
}
}
Мне интересно, хорошо ли я это реализовал?
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.wrapsody.demo.HistoryAuth
почему выдает эту ошибку?