0

I am saving my data into a selected database with my default method. However, there is 1 entity that i want to save on different table's column. How should i change on my method?

LoginBean.java

private String fullName_;
private String gender_;
private String phoneNumber_;
private String IC_;
private String email_;
private String Address_;
private String password_;
private String course;

List<String> courseOption;

public LoginBean(){

courseOption = new ArrayList<>();
    courseOption.add("Information Technology");
    courseOption.add("Business Management");
    courseOption.add("Engineering");
    courseOption.add("Design");

//getter and setter

    public String saveUserStudent(LoginBean loginBean){
    UserDao dao = new UserDao(); 
    User user = new User();
    user.setFullName(loginBean.getFullName_());
    user.setGender(loginBean.getGender_());
    user.setPhoneNumber(Integer.parseInt(loginBean.getPhoneNumber_()));
    user.setIc(loginBean.getIC_());
    user.setEmail(loginBean.getEmail_());
    user.setAddress(loginBean.getAddress_());
    user.setPassword(loginBean.getPassword_());
    dao.saveUserStudent(user);

    Map<String,Object> sessionMapObj = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
        sessionMapObj.put("msg", "Data "+user.getIc() +"successfull!");

my dao.saveUserStudent(user) is the method name that has been saved on the directed database. Is there anything i should add or change on the source code?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • 2
    The same way as you would without JSF and in a unit test (and PLEASE check your tagging, nhibernate is for .Net. And you should use jpa, not hibernate directly and... ) – Kukeltje Mar 17 '20 at 08:11
  • 1
    Please read [ask] – Jasper de Vries Mar 17 '20 at 08:12
  • 1
    And please read https://stackoverflow.com/questions/53209854/how-to-use-spring-dao-methods-with-managedbean-object (including both its duplicates) – Kukeltje Mar 17 '20 at 08:15
  • 1
    and please format the code in a more readably way – Kukeltje Mar 17 '20 at 08:15
  • @Kukeltje sorry for the poor writing, i have been starting to getting by with the forum around a week. Thank you for your feedback. –  Mar 17 '20 at 08:23

0 Answers0