2

I went to an interview into a IT consultancy company last friday.

The Interviewer asked me about my project and what was my participation in it.

Suddenly he threw one question on hibernate. His question was as follows

"If i have an project which has been developed in an MVC architecture using Java EE environment, but using JDBC for Database interaction, how will i integrate Hibernate into it. I don't want to disturb the existing code, all the previous JDBC code should be intact. "

I told him that we an add all the features of hibernate in the existing code, as it only requires Config files, Entities thats it. The old code of JDBC may itself be using Datasourse for getting connection, the same datasourse can be looked up using JNDI to build a session factory in Hibernate, not a big deal.

But the interviewer was not happy with my answer, he needed some more explanation. I was not able to impress him.

So can you please suggest what should be the probable answer for the above question. Or at least give me one hint so that i can come to an answer.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Rahul Shivsharan
  • 2,481
  • 7
  • 40
  • 59

3 Answers3

3

I think he wanted answer like the following.

Typical application design requires layers separation. There are the following classic layers: web tier, business logic and DB. There is a thin layer named DAO (Data Access Objects) that is written in java and plays a role of "middleman" between business logic and DB. It sounds that this tier is implemented using plain JDBC.

So, there is not a problem to replace this and only this layer with Hibernate based one.

Now you can add more details about how you are configuring Hibernate and integrate it with the rest of your application.

AlexR
  • 114,158
  • 16
  • 130
  • 208
1

Not an exact answer and you did not mention which framework your application use but if your application uses Spring framework, this my question and its answer's will be helpful to you but my question is reverse as I wanted to integrate jdbc with hibernate.

Community
  • 1
  • 1
Nandkumar Tekale
  • 16,024
  • 8
  • 58
  • 85
0

I think he was probably looking for you to explain how you might:

  • put Hibernate wrappers around existing SQL queries, or
  • create Hibernate bindings for legacy SQL tables, or
  • integrate Hibernate and classic JDBC using container-level transactions.

(It is clear that he was not asking about how you would replace the old JDBC code with Hibernate code ...)

But of course, you'd really need to ask him what knowledge / experience he was expecting you to demonstrate in answering the question.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216