Search code examples
hibernateentity

How can I add another variable in my entity?


I am really new to hibernate/spring data and I had my entity set up just fine, but now I tried to add another variable (orchestra) to my entity, but I always get the following error: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: backend.entity.Orchestra, at table: group_table, for columns: [org.hibernate.mapping.Column(orchestra)]

What do i have to do to update my Entity?

@Entity
@Table(name = "group_table")
public class Group {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private UUID id;

    @Column
    @NotNull
    private String name;

    @Column
    private Orchestra orchestra; //<- trying to add

Solution

  • Your mapping is not correct. Packaging for backend.entity.Orchestra suggests it is an @Entity, therefore you need to:

    • remove the @Column annotation
    • mark your relation as either @OneToOne or @ManyToOne.
    • possibly specify join columns, depending on your db structure.