Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session comes as null while inserting into database

 
Dinesh Remje
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Hibernate and while searching on the net i came to know some method for inserting into database.
I used those method in my code, but now I am facing a new problem that is my session comes as null and hence my program throws an exception before saving the object

Now exception is thrown on the getSessionFactory().openSession(); it comes as null.
the exception thrown is as follows:

Please let me know the solution for it. Wasted a load amount of time in debugging this . Please guide me.
 
Dinesh Remje
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed my code to somewhat like this

But now it gives me some another error which is as follows


I am not able to understand why it giving me an error for the QuestionBank in Exam.java file for which the code is
[code=java][
@ManyToMany(cascade = { CascadeType.ALL })
@JoinTable(name = "QuestionBank_Exam_Mapping", joinColumns = { @JoinColumn(name = "examid")},
inverseJoinColumns = { @JoinColumn(name = "questionid") })
private Set<QuestionBank> questionBank = new HashSet<QuestionBank>();
/code]

I want to create just exam entry by giving an userinteface to the user where he will enter some required parameters like exam name, exam date, exam duration etc. There is a another dependency where again i have to make an entry for the exam created by using the examid in advt_exam_post table mapping. I have advtid and postid in session, so i can make an entry in that table. My confusion is why it is showing me error for the questionbank. In questionbank and exam table mapping there is dependency with the examid and questionid, which will be filled only when the user selects a particular question for a particular exam. Currently I am fetching the Questions form the QuestionBank table and using it in the controller for creating exam but still it gives me the same error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic