Advertisement
Home > Hibernate Tutorial > Interview questions answer > discussionPlease log in to add or reply to any matter<- requires login or
RMI Example

Home > Hibernate Tutorial > Interview questions answer > discussion
Struts Tutorials:
Struts2 Tag CheckBoxList
, Checkbox, Iterator, IF
Struts2 Tag Library Example Struts2 Tiles Example Struts2 Tiles I18N Example Struts2 Questions Struts Tiles I18N Example Struts Eclipse MVC Struts2 Tags Struts2 Example and Tutorial Struts MVC Struts2 Validation
Hibernate Tutorials: Hibernate Case Study Class Hierarchy Persist Example Using Hibernate Interceptor Hibernate Questions with Answer Hibernate Many-to-Many Mapping Example Hibernate one-to-many Mapping Example Hibernate and ORM tools Spring Hibernate Example Hibernate SessionFactory Example Hibernate Mapping Class Hierarchy Hibernate Questions Hibernate SessionFactory Questions Spring Hibernate Example: Spring Hibernate Case Study

Written By : Amit
Title :
ways create Hibernate SessionFactory
Description : Example
More...


Written By : Amit
Title :
Spring Hibernate Integration example
Description : Example
More...


Written By : Amit
Title :
ORM Hibernate Best FIT
Description : Discussion
More...


Written By : Amit
Title :
One to Many mapping example
Description : Code
More...


Written By : Amit
Title :
Many to Many Mapping Example
Description : code
More...


Written By : Amit
Title :
Interview questions answer
Description : discussion
More...


Written By : Amit
Title :
Interceptor use log SQL statements
Description : example code
More...


Written By : Amit
Title :
Class Hierarchy Persist example
Description : code
More...

Hibernate Tutorial,Interview-questions-answer,discussion
Author : Amit
Date (Year/Month/Date): 2009-02-18 Hibernate Interview Questions with answer
Hibernate Question :
 What are the different Transaction Factories available with Hibernate?
Hibernate Answer :
There are three different types of Transaction Factoryavailable with Hibenate 3.2 as JDBCTransactionFactory,
JTATransactionFactory and CMTTransactionFactory.

Hibernate Question :
Which one is the default    transaction factory in    Hibernate 3.2?

Advertisement
Hibernate interview answer JDBCTransactionFactory is the default local transaction factory withHibernate 3.2.
Hibernate interview question
Can Hibernate Session Factory be
bound to JNDI?

Hibernate interview answer
Yes, by configuring in
hibernate.cfg file, session
factory can be bound to initial
context (as defined by
properties hibernate.jndi.url
and hibernate.jndi.class).

Hibernate interview question
Can Hibernate be used to call
stored procedures and SQL
statements?

Hibernate interview answer
Yes, there are provision in Hibernate 3.2, for defining
callable statements and SQL in mapping HBM files.

Hibernate interview question
Can the custom SQL be defined for creation of Java entity
object by loading values from database tables and
populating Java Object?

Hibernate interview answer
Yes, Javaentity objects can be loaded with custom SQL
queries and can be defined in HBM file in form of
HQL (Hibernate Query Language).

Hibernate interview question
What are the different Fetching Strategies available
with Hibernate 3.2?

Hibername interview answer
There are four different Fetching standards available in
Hibernate3.2, as follows: join fetching, select fetching,
batch fetching, sub-select fetching.

Hibernate interview question
What are the different types of statistics available in
Hibernate 3.2?

Hibernate interview answer
Different types of statistics like QueryStatistics,
CategorizedStatistics, CollectionStatistics, EntityStatistics
etc., available in Hibernate 3.2.

Hibernate interview question
How can you get a handle on Hibernate Statistics?

Hibernate interview answer
If Hibernate is deployed in a JMX enabled Application
server, then Hibernate provided a statistics service,
that can be registered as MBean with JMX server and be
used to retrieve different types of statistics available.
Hibernate statistics can be obtained from session
factory as well.

Hibernate interview question
Can Hibernate be used to map persistent entity POJO to
XML files?

Hibernate interview answer
Yes, Hibernate can be used to mapp XML file/tags to
POJO entity classes.

 Hibernate Question : If there are
 multiple databases to be
 used to interact with domain
 classes, how can session
 factory be able to manage
 multiple datasources?

Hibernate Answer :
 Each datasource will be
 configured to each session
 factory, and to use a single
 database, a session is
 created to use database.
Question : What is lazy initialization in Hibernate?

Answer :
When there is an association of one-to-one, or
one-to-many, or many-to-many between classes,
and on creation of one object, it has to be
decided whether to bring associated objects along
with this object or not. By setting lazy="true"
we instruct Hibernate not to bring the associated
object/objects during creation of the required object.
By setting lazy="false", it is the reverse, this means
we instruct Hibernate to bring all the associated
objects also at the time of returning the associating
object.

Hibernate interview Question : if there any impact on performance
by this attribute lazy ?

Hibernate interview Answer :
This is purely a configuration time decision one has
to take to use lazy attribute and its value (true/false)
appropriately. As SessionFactory is created once and reused,
all the configuration setting in HBM file is read once,
and cann't be changed at runtime.

Hibernate Question : What are the different states
of an instance in Hibernate?

Hibernate Answer :
There are three states that exist for any instance of a
class. These are transient, persistent and detached.
Those instances that are created but not associated with
any session or not saved in database are trasient objects.
Those instances that are created and be used in any of the
methods like save, saveOrUpdate, update of Session are
called persistent objects.
Those instances that were used in Session methods like save,
saveOrUpdate or update to be inserted or updated in database
table, and then session is flushed and closed, now these
objects are in JVM, but these are not bound to any session.


Hibernate interview question
How can certain type of logic executed on execution of
CRUD operation of session, without duplicating it across
many places in code base?

Hibernate interview answer
Hibernate Interceptors can be used to receive callback
for certain type of events or operations like save, delete,
load, update of session. Session Factory level interceptor
and session level interceptor. These Interceptors can be
used to have code for certain type of logic to be called
for every lifecycle method of session.

Hibernate interview question
How can multiple threads access session factory
simulteneously to create session instance?

Hibernate interview answer
session factory is thread-safe, so it is okay to be used
by many threads to have session from session factory,
but I think session is not thread safe and it should be
used by one thread at a time, and after use,
session has to be flushed and closed.

Hibernate interview question
How many ways Hibernate manages concurrency ?

Hibernate interview answer
Hibernate has different ways of managing concurrency.
These are  automatic versioning, detached object and
extended user sessions.

Hibernate interview question
What is the difference between uni-directional and
bi-directional associations?

Hibernate interview answer
uni-directional association allows object creation from
one direction only. Bi-directional association allows
object querying from both directions of fetching object
instances.

A->B, now querying A, can provide information on B as
well, based on lazy parameter, but in case of A<->B,
querying either A or B, will have value of B or A as
well, respectively.

Hibernate interview Question
What are the different contextual session in Hibernate?

Hibernate interview answer
There are three different types
of contextual session Hibernate
provides, these are JTA session
context, local thread session
context and managed session
context. JTA session context is
applicable in case Hibernate
session is running in JTA (Java
Transaction API), request thread
level session scoped applicable
in case of local thread session,
and managed session, requires
application to open, close and
flush session, so creation of
session should be handled by
application only.

Hibernate interview Question
Can you tell us difference between Hibernate HQL over SQL?

Hibernate interview answer
HQL is fully object oriented, with support for object
inheritence, polymorphism and association, but SQL
is more of Relational with structured form of queries.

Hibernate interview Question
What are the different scopes one can introduce while using
Interceptors with Hibernate?

Hibernate interview Answer
Probably, one can use interceptors with hibernate Session
scoped or SessionFactory scoped contexts, while using
Interceptors with Hibernate.

Hibernate interview Question
How many ways client application that uses Hibernate to
react to certain events?

Hibernate interview Answer
Probably, if I am not wrong, two ways one can react/act
to certain events generated out of Hibernate Framework.
These are either Interceptors or event systems.

Hibernate interview Question
Can I be able to persist a XML DOM object tree to database
by defining mapping between XML DOM to database table,
without using POJOs?

Hibernate interview Answer
Yes, one can use Hibernate mapping to persist XML DOM tree
hierarchy to database tables.

Advertisement
Disclaim: These materials mentioned as above, are my understanding of Hibernate, for details and complete information, please refer to Hibernate site http://www.hibernate.org/
 
Replied By ->
dsubram
what is the default scope in hibernate- session or prototype?
 

Commented By ->
Amit
Friends,

Some of the Questions with my answer on Hibernate , listed below:
Please don't hesitate to correct me if I am wrong.

Hibernate Question :
What is a persistence context in Hibernate?

Hibernate answer
Hibernate Session is referred as persistence context.

Hibernate Question :
What is Java identity and how is it different from persistence
identity?

Hibernate answer :
Java identity can be referred to as an in-memory location of 
an object, while persistence identity can be established once 
there is a record in datastore with a primary key field value.

Hibernate question :
While using Hibernate, is it responsility of developer to make
sure Java identity and persistence identity are same for a 
perticular persistence context?

Hibernate answer :
It is Hibernate that guarantees that persistence identity and
Java identity are same/equivalent for a persistence entity, in
a perticular persistence context.

Hibernate Question
What are the different states available for 
a persistent class to be in, for a particular persistence context?

Hibernate answer :
For a particular persistence context, there can three states, such
as persistent, transient and detached, in which any Hibernate related
persistent class can be present.

Please write your Comment on this Matter
(This will be visible if found suitable):
Name: *
Email (will not be displayed): *
Matter: *
28,4
Enter bigger number from above :*
Home > Hibernate Tutorial > Interview questions answer > discussion
Visitor/User submitted related resources:
(Visible upon review and approved by this site Administrator)
Referred By Name *:
Resource URL *: (e.g, URL should be starting with http://www.-----.---)
 
Resource Short Description *:
31,21
Enter bigger number from above : *

Please log in to add or reply to any matter<- requires login
Log in or Register
This List is generated as on 2009-07-12 (YYYY-MM-DD)
#Discuss-these : questions-and-answer : Interview-Questions-on-Java
#Question-on-Session-Factory-Creation : SessionFactory : Hibernate-Tutorial
#On-Hibernate : Interview-Questions : Hibernate-Tutorial
#Example : mapping-class-hierarchy-table-per-subclass : Hibernate-Tutorial
#Example : ways-create-Hibernate-SessionFactory : Hibernate-Tutorial
#Example : Spring-Hibernate-Integration-example : Hibernate-Tutorial
#Discussion : ORM-Hibernate-Best-FIT : Hibernate-Tutorial
#Code : One-to-Many-mapping-example : Hibernate-Tutorial
#code : Many-to-Many-Mapping-Example : Hibernate-Tutorial
#discussion : Interview-questions-answer : Hibernate-Tutorial
#example-code : Interceptor-use-log-SQL-statements : Hibernate-Tutorial
#code : Class-Hierarchy-Persist-example : Hibernate-Tutorial
#discussion : Case-study-Hibernate : Hibernate-Tutorial
#With-Answer : Hibernate-Interview-Questions : Hibernate-Tutorial
#Discussed : Hibernate-Interview-questions-answer : Hibernate-Tutorial
#Question : Hibernate-Transaction : Hibernate-Tutorial
#Example-Case-study : Contextual-Session : Hibernate-Tutorial
#Design-with-example-code : Struts2-Hibernate : Hibernate-Tutorial
#Hibernate-query : Hibernate-Criteria : Hibernate-Tutorial
#Hibernate-Criteria-Example : Hibernate-Filter-Example : Hibernate-Tutorial
#Hibernate-Filter-Example : Hibernate-Filter : Hibernate-Tutorial
#Hibernate-Sample : Hibernate-many-to-one : Hibernate-Tutorial
#Hibernate-Sample-Example : Hibernate-named-query : Hibernate-Tutorial
#Composite-Primary-Key : Hibernate-Composite-Key : Hibernate-Tutorial
#Mapping-Example : Hibernate-one-to-one : Hibernate-Tutorial
Copyright © 2008-2009, Interview-Questions-Tips-Forum, All Rights Reserved.
CONTACT    PRIVACY POLICY    DISCLAIMER

This web site provides some of the information about various technologies, example 
code, tips, tutorials etc. Like any printed matterials, content of these pages may 
become out of date over a period of time. Therefore all visitor/users of this web 
site are requested/advised to refer to the originating parties/sources for the 
latest changes and happenings for detailed information. This information is not 
intended to be a substitute for the original reference provided by the originating 
parties/sources.