Я пытаюсь выполнить операцию CRUD с использованием остальных данных, но после вставки первой записи в базу данных я не могу получить данные из базы данных как json
, вот мой код:
Класс модели
@Entity
@Table(name="ledger_group")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
@EntityListeners(AuditingEntityListener.class)
@Data
public class LedgerGroup implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Integer id;
@Column(name = "key_code")
private Integer keyCode;
@Column(name="ledger_group")
private String ledgerGroupName;
@ManyToOne
@JoinColumn(name = "parent")
private LedgerGroup parent;
@OneToMany(mappedBy = "parent")
@JsonIgnore
private List<LedgerGroup> ledgerGroupList;
@CreatedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name="timestamp_created")
private Date timestampCreated;
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name="timestamp_modified")
private Date timestampModified;
//bi-directional many-to-one association to LedgerAccount
@OneToMany(mappedBy="ledgerGroup", cascade = CascadeType.ALL)
@JsonIgnore
private List<LedgerAccount> ledgerAccounts;
//bi-directional many-to-one association to User
@Column(name="user_created")
private String createdBy;
//bi-directional many-to-one association to User
@Column(name="user_modified")
private String lastModifiedBy;
public LedgerGroup() {
}
}
Репозиторий
@RepositoryRestResource
public interface LedgerGroupRepository extends PagingAndSortingRepository<LedgerGroup, Integer> {
}
Здесь ошибка из браузера
Вот ошибка с консоли
2018-10-11 10:27:27.911 WARN 11122 --- [nio-8080-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Invalid Object Id definition for com.icloud.micro.model.LedgerGroup: cannot find property with name 'id'; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid Object Id definition for com.icloud.micro.model.LedgerGroup: cannot find property with name 'id' (through reference chain: org.springframework.hateoas.PagedResources["_embedded"]->java.util.Collections$UnmodifiableMap["ledgerGroups"]->java.util.ArrayList[0])]