hibernate interview questions part1
DESCRIPTION
java hibernate interview questionsTRANSCRIPT
Hibernate interview Questions Part1 Posted by Stephen thangaraj at 18:28 What is Hibernate?Hibernate is a powerful, high performance object/relational persistence and uery ser!ice"#t is anopen$source technologywhichfits well bothwith%a!aand"&'(technologies"Hibernate letsde!eloperswritepersistenceclasseswithhibernateueryfeaturesofH)*withinprinciplesof+bject +riented paradigm"#t means one can includeassociation,inheritance,polymorphism,composition andcollection of these persisting objects tobuild applications"Hibernate Architecture(he main objecti!e of Hibernate is to relie!e the de!elopers from manual handling of S)*s,%,-./P#s for resultsets handling and it helps in 0eeping your data portable to !arious S)* databases,justby switching the delegate and dri!er details in hibernate"cfg"1ml file"Hibernate offers sophisticatedueryoptions, youcanwrite plainS)*, object$orientedH)*2Hibernate )uery *anguage3, or create programmatic criteria and e1ample ueries" Hibernate canoptimi4e object loading all the time, with !arious fetching and caching options"Some snapshots of Hibernate:$5ree open source$++ .oncepts can be implemented"$/ rich !ariety of mappings for collections and dependent objects$&o e1tra code generation or bytecode processing steps in your build procedure$6reat performance, has a dual$layer cache architecture, and may be used in a cluster$#ts own uery language support$'fficient transaction handling$(he %a!a Persistence /P# is the standard object/relational mapping and persistence managementinterface of the %a!a '' 7"8 platform which are implemented with the Hibernate /nnotations andHibernate 'ntity9anager modules, on top of the Hibernate .ore"2/s part of '%-:"8 spec3Why Hibernate?(he reasons are plenty,weighing in fa!or of Hibernate clearly"$.ost effecti!e"%ust imagine when you are using '%-s instead of Hibernate"+ne has to in!est in/pplication Ser!er2;ebsphere,;eblogic etc"3,learning cur!e for '%- is slow and reuires specialtraining if your de!elopers are not euipped with the '%- 0now$how"$(he de!elopers get rid of writing comple1 S)*s and no more need of %,-. /P#s for resultsethandling"'!en less code than %,-."#n fact the ++ de!elopers wor0 well when they ha!e to dealwith object then writing lousy ueries"$Highperformance then'%-s2if we gobytheir industryreputation3,whichitself a containermanaged,hea!yweight solution"$Switching to other S)* database reuires few changes in Hibernate configuration file and reuiresleast clutter than '%-s"$'%-itselfhasmodeleditselfonHibernateprincipleinitslatest !ersioni"e" '%-:becauseofapparent reasons"What is ORM ?+bject ehicle as .ar and @tility>an"1" (able per concrete class with unions#n this scenario there will be 2 tables(ables: .ar, @tility>an, here in this case all common attributes will be duplicated"2" (able per class hierarchySingle (able can be mapped to a class hierarchy(here will be only one table in database named =>ehicle= which will represent all attributes reuiredfor all three classes"Here it is be ta0en care of that discriminating columns to differentiate between .ar and @tility>an:" (able per subclassSimply there will be three tables representing >ehicle, .ar and @tility>anQ) How wi(( you configure Hibernate? Answer* (he configuration files hibernate"cfg"1ml 2or hibernate"properties3 and mapping files D"hbm"1ml areused by the .onfiguration class to create 2i"e" configure and bootstrap hibernate3 theSession5actory, whichinturncreates theSessioninstances" Sessioninstances aretheprimaryinterface for the persistence ser!ice"E hibernate"cfg"1ml 2alternati!ely can use hibernate"properties3: (hese two files are used toconfigurethehibernatese!ice2connectiondri!erclass, connection@