| |
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 :
Interview Questions
Description :
On Hibernate More...
|
Written By : Amit
Title :
mapping class hierarchy table per subclass
Description :
Example More...
|
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...
|
| Tags/Keywords : Hibernate interview questions, Hibernate, Interview, Questions Author : Amit Date (Year/Month/Date): 2009-03-31
Hibernate Question :
Can the strategy of LAZY load for the dependent domain classes,
be change once SessionFactory is created?
Answer to the Best of my knowledge:
No, as SessionFactory is loaded/created once for the entire
lifecycle of the application,and while creating Hibernate
SessionFactory, appropriate HBM XML file is read and these
configuration are used for creating or instantiating Hibernate
SessionFactory, so it is logically not possible as,
SessionFactory is not going to refresh but destroyed and
recreated. And for different modules from the same
application, if requires LAZY as true / false, then using a single
Hibernate SessionFactory won't be able to serve both these
Persistent Object loading strategies. | | Books/References :
| Hibernate Interview Questions 1: |
Does Hibernate Session Object has any cache associated with it by default ?
|
| Hibernate Interview Answer 1: |
Yes, first-level caching is a mandatory requirement for Hibernate Session Object.
|
| Hibernate Interview Questions 2: |
Is there any cache associated with Hibernate SessionFactory Object?
|
| Hibernate Interview Answer 2: |
Yes, there is an optional second-level cache with Hibernate SessionFactory
object. |
| Hibernate Interview Questions 3: |
Can a single Hibernate Session object be used across multiple threads
running within a process |
| Hibernate Interview Answer 3: |
No, Hibernate Session is basically single-threaded and not to be used across
multiple threads. |
| Hibernate Interview Questions 4: |
Is this same for Hibernate SessionFactory object as well?
|
| Hibernate Interview Answer 4: |
No, Hibernate SessionFactory is basically thread-safe, thus can be re-used
across multiple threads and multiple Transacions as well.
|
| Hibernate Interview Questions 5: |
How can the second-level caching for Hibernate SessionFactory object be
disabled?
|
| Hibernate Interview Answer 5: |
By setting appropriate hibernate.cache configuration related properties, one
can enable/disable second-level caching for Hibernate SessionFactory object
but only for once before SessionFactory is created |
| Hibernate Interview Questions 6: |
Is it possible to use Hibernate Session object with the scope and context
defined by JTA Transaction ? |
| Hibernate Interview Answer 6: |
Yes, starting with Hibernate 3.0.1 version, Sessionfactory.getCurrentSession method
has the scope and context defined by the running JTA Transaction scope and context.
But as of Hibernate 3.1 version, getCurrentSession method of Hibernate
SessionFactory has the current Session Scope and Context controlled by pluggable
current Session Context class, defined in configuration parameter such as
hibernate.current_session_context_class. |
| Hibernate Interview Questions 7: |
As of Hibernate 3.1 version can you be able to explain how many ways
scope and context of Hibernate current contextual session be handled? |
| Hibernate Interview Answer 7: |
As of Hibernate 3.1 version, Hibernate has three ways to handle current contextual
session, such as
JTASessionContext
ThreadLocalSessionContext
ManagedSessionContext.
|
Hibernate Questions with answer as of 19th Jan 2010 :
Hibernate Interview Questions 1 :
What is the difference between class tag and component tag in Hibernate
from the persistence perspective?
Hibernate Interview answer 1 :
class tag refers to an Entity that is persisted with an identifier,
while component tag means the POJO associated with component tag is
persisted along with contained object as a value type.So it doesn't require
an identifier, while the contained object has an entity reference, not for the
component object.
Hibernate Interview Questions 2 :
What is the difference between component and dynamic component?
Hibernate Interview answer 2 :
Component in Hibernate world, means something that is embeded in
a contained object and there exist a composition style of binding between
the contained object and the component object. So component is declared
inside a class tag, just to say one type of use.
Dynamic-component has the same characteristics as component but there exists
a difference in the way dynamic-component can be used to map a bean's attribute,
this can be of type java.util.Map with the key defined in mapping file
and corresponding value from the table's column.
So with dynamic-component, there can be possibility of changing the attribute
key/value pair during deployment time, just by changing the name and
column values in the mapping configuration file.
|
|
|
Commented By -> Girish | |-Hibernate Question 1:
| Can a Hibernate Session, that is retrieved/created from a Hibernate
| SessionFactory, be shared across multiple concurrent Thread/Requests?
|
|-Hibernate Answer
No, as Hibernate Session is not Thread-Safe, so sharing it with
multiple concurrent Thread of execution or request will have
concurrentcy issues.
It is always better to use a single Hibernate Session for a
single transaction, that means as long as the transaction is
running or not commited, a single session can be used. As a
Transaction is running in isolation for each Thread or request.
|-Hibernate Question 2:
| What is a good approach of handling Hibernate Session, in case of
| any database exception or Hibernate Exception that is occuring
| while a Hibernate Session is in use?
|
|-Hibernate Answer
As Hibernate Session caches Persistent Object, in case of any Database
exception or Hibernate Exception occuring, then Session cache might
have some stale data or Persistent Object not in sync with Database.
So it is always better to rollback Transaction, close Session, in this
circumtances.
|-Hibernate Question 3:
| How Hibernate manages Transaction timeout in Managed and Non-managed
| environments?
|
|-Hibernate Answer
In Managed environment, that is JTA transaction can handle timeout,
so Hibernate delegated Transaction timeout task to JTA Transaction.
But in non-managed environment, Developer has to explicitly specify
Transaction timeout parameter while using Transaction from
Hibernate Session by using setTimeOut(time in seconds).
But this feature cannot be fully compared with JTA based Transaction
timeout operation.
Any one wants to comment on these questions and answer, please do so. |
| | |
Commented By -> Amit | Hibernate Question:
Question 1 :
What is the first level cache and the second level cache in Hibernate?
Answer 1:
First level cache is associated with Hibernate Session object, and is
mandatory, while second level cache is optionally associated with Hibernate
SessionFactory instance.
Question 2:
Which cache is cluster-level, first level or second level?
Answer 2:
Second level cache is optional, but can be cluster-level.
Question 3:
How many different instance states exist for an instance of a persistent
class while using Hibernate?
Answer 3:
There are three different instance states, such as Transient, Persistent,
and detached.
Questions 4:
What are the instances having persistent entity?
Answer 4:
Persistent and detached instances are having persistent entity.
Question 5:
Can you please explain these three instance states with help of
an example?
Answer 5:
Suppose in a web application, if a user information is passed from
the registration page shwon on browser for the first time, then the
UI helper class will be creating an instance of the User class, and
populate all the relevant details onto the USER object. At this level
USER object has a Java identity but no persistent identity. So this
USER object is transient instance state. Then if this USER instance
is sent to the business level, and with help of DAO, is stored in
backend db, then this USER instance has got both Java and Persistent
identities, so is having Persistent instance state.
If this USER object is again sent to the UI level for displaying
an edit screen, then this USER instance in UI tier is detached instance
state, as is having both Java and persistent identity. But Hibernate
cann't relate Java and persistent identities for detached instance states.
|
| | |
Commented By -> chinnababu | This is really good and very much helpful. Thank you. |
| | Are you interested in solving a very interesting Technology Stack while Playing this Game 
|
|
| Home >>> Hibernate Tutorial >>> Hibernate Interview questions answer >>> Discussed |
|
|
Visitor/User referred related external URL:
(Visible upon review and approved by this site Administrator)
|
|
|
|
|
<- requires login | Log in or Register | |
Copyright © 2008-2009, Interview-Questions-Tips-Forum, All Rights Reserved. | CONTACT PRIVACY POLICY DISCLAIMER |
 |
Terms of Use and Disclaimer :
This web site provides some of the information about various technologies, example
code, tips, tutorials etc. Like any printed materials, 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.
By accessing and using this website in any ways, including, without
limitation, browsing the website pages, using any information, using any content and/or
downloading any materials, you agree to and are bound by the terms of use
described in this page and Usage Terms and Conditions.
If you do not agree to all of
the terms and conditions contained in the terms of use described in this
page and Usage Terms and Conditions, do not use this
website in any manner. If you are using the website on behalf of your
employer, you represent that you are authorized to accept these Terms of Use
on your employer's behalf.
All Trademarks are property of their respective owner. Appropriate measure is being
taken for providing accurate and up-to-date information but like any printed materials,
these blog(s)/contents may eventually be outdated one day, so if you are using any
of these information, please refer original content/documentation from respective sources.
And under no circumstances shall the Author of these contents and/or this web site
be liable for any loss, damage, expense incurred or suffered which is claimed to have
occurred because of usage of the contents of this web site.
If you have any questions/queries/feedback/suggestions then please write to this web
site owner at contact.
|  |
|
|
|
|
|