In a OneToOne relationship,I Can't persist The fields of Adresse but I get no error for School fields it's give this error:
javax.el.PropertyNotFoundException: /inscription/school-inscription.xhtml @29,91 value="#{createBn.school.adresse.country}": Target Unreachable, 'null' returned null
here is the view:
<h:inputText id="name" value="#{createBn.school.name}" pt:placeholder="ex: Dalton" />
<h:inputText value="#{createBn.school.creationDate}" pt:placeholder="31-12-2000" />
<h:selectOneMenu value="#{createBn.school.adresse.country}" styleClass="form-control">
<f:selectItems value="#{countriesList.countries}" />
</h:selectOneMenu>.....
so createBn:
@Named
@SessionScoped
public class CreateBn implements Serializable{
private static final long serialVersionUID = 1L;
private School school;
@EJB
private SchoolPr schoolPr;
public CreateBn(){
user = new User();
school = new School();
}
public void createSchool(){
schoolPr.createSchool(school);
}
and here are the School Entity and the Adress Entity:
@Entity
@Table(schema = "school", name = "school")
public class School implements Serializable {
....
private String name;
@OneToOne @JoinColumn(name = "adressId")
private Adresse adresse;
//getters +setters
Adress:
@Entity
@Table(schema = "school", name = "adress")
class Adresse implements java.io.Serializable {
..
private String country;
//getters +setters
Ps: I already see similar cases here but nothing helps + I delete most of the code posted here like ID fields and so, all getters and setters are implemented.