0

I have a class named theme , and a theme can have sub_themes. i want to do mapping between the class theme and the object sub_theme of type theme.

Example :

@Entity
@Table(name = "themes")
public class Theme {

    @Id
    @GeneratedValue
    @Column(name = "Id", nullable = false)
    @Getter @Setter private Long id;
    @Column(name = "titre", nullable = true)
    @Getter @Setter private String titre;


    @Getter @Setter private Theme sub_theme;


    public Theme() {
    }

}

How can i do mapping between theme and sub_theme, and how to persist a theme with its sub themes ?

Thank you in advance

MsIsem
  • 23
  • 8

1 Answers1

-1

You need to add annotation @ManyToOne on sub_theme field.