Answer the question
In order to leave comments, you need to log in
Why is the entity not mapped?
There are two entities.
@Entity
@Table(name = "entry")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Entry {
@Id
@GeneratedValue
private Long id;
@Column(name = "entry_date")
private Date date;
@Column(name = "title")
private String title;
@Column(name = "content_id")
@OneToOne(mappedBy = "entry", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Content content;
}
@Entity
@Table(name = "content")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Content {
@Id
@GeneratedValue
private Long id;
@Column(name = "content_text")
private String content_text;
@OneToOne
@JoinColumn(name = "entry_id")
private Entry entry;
}
@Bean
CommandLineRunner runner(EntryRepository entryRepository) {
return args -> {
Content content = new Content();
Entry entry = new Entry();
content.setId(1L);
content.setContent_text("ABC");
content.setEntry(entry);
entry.setId(1L);
entry.setDate(new Date());
entry.setTitle("DEF");
entry.setContent(content);
entryRepository.save(
entry
);
};
}
@Column(s) not allowed on a @OneToOne property: com.slandshow.bank.models.Entry
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question