SlandShow
@SlandShow
70% of my body is made of movies.

Почему не мапится энтити?

Есть две энтити.

@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
  • Вопрос задан
  • 494 просмотра
Пригласить эксперта
Ответы на вопрос 1
al_gon
@al_gon
@Column -> @JoinColumn
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы