Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get session of one class in another class in Hibernate?

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am making an application in which I am saving Image in database so I am using method


instead of createBlob() (it is deperacted)

But I am getting Null Pointer Exception this is My DAOImpl class


I am getting Null Pointer Exeception because I am calling from some other class like this


How to get session there?

 
Roel De Nijs
Sheriff
Posts: 10763
148
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishor Joshi wrote:How to get session there?

That's not required at all!

If you have a Person entity with an instance variable of type byte[] you can simply do as in this example:
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!