Property mapping has the wrong number of column exceptions - Play-framework

I start with the play framework. Take a question about JPA and mappings in the game structure,

I have a student table and a mentor table attached to each other.

Student table:

id, name, class, grade

Mentor Table:

id, name, department, student_id

In the foregoing, a mentor may or may not have a student associated with him / her. I am doing a one-to-one mentor model,

@OneToOne
@JoinColumn(name="fk_student_id", referencedColumnName="id")
private student Student;

When I try to run this, I get

JPA error occurred (EntityManagerFactory cannot be built): property mapping has the wrong number of columns: models.Mentor.student type: models.Student.

I am sure that I have displayed all Student fields as shown below,

Student.java

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

@Column(name="name")
private String name;

@Column(name="class")
private String cls;

@Column(name="grade")
private String grade;

What am I missing here?

Thank you for your time.

Regards, Abi

+5
2

, Play Framework? Play JPA . :

@OneToOne
@JoinColumn(name="fk_student_id", referencedColumnName="id")
private student Student;

. -

@OneToOne
@JoinColumn(name="fk_student_id") //removed the id reference, let JPA manage it
public Student student; //note order of class and var name

, "id", . ?

+2

GenericModel, - id

:

GenericModel:
play.db.jpa.Model. JPA play.db.jpa.GenericModel. , .

, . UUID, , -.

@Entity
public class User extends GenericModel {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String id;

@Required
public String name;

@Required
@MaxSize(value=255, message = "email.maxsize")
@play.data.validation.Email
public String mail;
} 
0

All Articles