I'm trying to set up a relationship between two different tables on my database using spring jpa. However, each time i try to do a @OnetoMany or @ManytoOne i get the error mentioned in the title.
Student :
package EIC.com.example.Backend.Entity;
import org.hibernate.annotations.Cascade;
import javax.persistence.*;
@Entity
@Table(name = "etudiant")
public class Student {
@Id
@Column(name="Apogee")
private int id;
@Column(name="Prenom")
private String first_name;
@Column(name="Nom")
private String last_name;
@Column(name="Classement")
private int rank;
@Column(name="Filiere")
private String speciality;
@ManyToOne
@Column(name = "Offre")
private Offer school;
/* GETTERS SETTERS CONSTRUCTORS */
}
Offer :
package EIC.com.example.Backend.Entity;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
public class Offer {
@Id
@Column(name = "ID_OFFRE")
private int id;
@Column(name = "Type")
private int type; // 0 for DD 1 for MOBILITY
@Column(name = "Etablissement")
private String school;
@Column(name = "Filiere_Concerne")
private String target;
@Column(name = "Nb_place")
private int seats;
@Column(name = "Delai")
private Date limit;
@OneToMany
@JoinColumn(name = "Offre")
private List<Student> students=new ArrayList<>();
/* GETTERS SETTERS CONSTRUCTORS */
}
Dependencies :
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.2.RELEASE EIC.com.example Backend 0.0.1-SNAPSHOT Backend EIC project with Spring Boot and Angular
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>