I'm working on EJB3. I want to insert Null value in the table.
Eg. I'm having a table called "Students" which has columns fields such as
String name;
String class;
Set<Subjects> subjects;
subjects field have the JoinTable "student_subjects" with fields joinColumns
"student_name" of "Students" table and inverseJoinColumns
"subjects_name" of "subjects" table
What I want is when I add a new student there will be a entry in "Students" table.
Also in the "student_subjects" table. but values must be student_name (not null) and NULL for "subjects_name". Is it possible?
You need to use nullable attribute of the @Column JPA annotation.
@Column(nullable = false)
private String studentName;
@Column(nullable = true)
private String subjectsName;