Advertisement
Home > Hibernate Tutorial > Interview Questions > On HibernatePlease log in to add or reply to any matter<- requires login or
RMI Example

Home > Hibernate Tutorial > Interview Questions > On Hibernate
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 :
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...


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


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

Hibernate Tutorial,Interview-Questions,On-Hibernate
Author : Amit
Date (Year/Month/Date): 2009-01-28 Hibernate interview question 1: When or How will the Persistent objects become Transient Objects? Hibernate Interview answer : Persistent objects are those, that are having database/ persistence value with primary key value present in the domain object in memory. Transient objects are those, that are never associated with persistence and not having corresponding record / row in database table. Now when persistent object turns to Transient object? this situation may arise normally when the record is deleted from the database. In this case there is no way the domain object in memory be mapped to any particular persistence context. * Note from Author: If anybody has any difference of opinion, please write it by replying to this question. Hibernate interview question 2 : Can you use final class as domain class for making the instances as persistent object? Hibernate interview answer : Yes, one can use final classes for instantiating to become persistent object. Hibernate interview question 3 : What is the difference between Java identity and Persistence entity from Hibernate perspective? Hibernate interview answer : While a domain object is in memory, then the equals() and hasCode() methods can be used for identifying domain object in memory, this way Java identity of domain object can be established. While Persistence identity is related to the primary key column and its value present in database table. Hibernate interview question 4 : Under what circumtances, is it required to implement equals and hasCode methods? Hibernate interview answer : There are two situations, where it is required that equals() and hasCode() methods should be implemented are as follows: 1. When there is one to many or many to one or many to many mapping, and the many part is contained in java.util.Set for holding all the mapped objects. As implementing class for Set interface, like java.util.HashSet uses equals and hasCode for operating certain methods like containsKey etc. 2. When any detached object is to be added back another Hibernate Session for converting the detached object to persistent object. Hibernate interview question 5 : Can you have a final class implementing an interface and use it with lazy="true" ? Hibernate interview answer : Yes, it is quite possible. * Note from Author: If anybody has any difference of opinion, please write it by replying to this question.

Advertisement


Commented By ->
Guddu
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.

Commented By ->
Girish
Hibernate Interview question :
Is it possible to change LAZY loading strategy of persistent dependent object?
Like changing Lazy value from true to false.

Answer to the best of my knowledge on Hibernate
No, while Hibernate SessionFactory is getting instantiated by using configuration
parameters those are specified in HBM XML file, so once Hibernate SessionFactory
is created, it will have to be destroyed and re-created to be able to take any
changes in configuration, such as lazy value changed from true to false or
vice versa.


Commented By ->
Girish
Thanks for these Hibernate interview questions.
Can you provide some more questions, based on practical
questions from projects?

Commented By ->
Girish
Hibernate Interview question :
Is it possible to change LAZY loading strategy of persistent dependent object?
Like changing Lazy value from true to false.

Answer to the best of my knowledge on Hibernate
No, while Hibernate SessionFactory is getting instantiated by using configuration
parameters those are specified in HBM XML file, so once Hibernate SessionFactory
is created, it will have to be destroyed and re-created to be able to take any
changes in configuration, such as lazy value changed from true to false or
vice versa.


Commented By ->
Amit
Hibernate Question 
what are the differences between Projections and Restrictions in Hibernate?

Answer to Hibernate Question
In Hibernate, Projections can be used to manipulate groups functions, like
in SQL we have group functions like COUNT, MAX, MIN, AVG, SUM, DISTINCT etc.

While Restrictions can be used with conditional operations such as in SQL
we have like, greater than (>), less than (<), equals to, in, between, is null or
not null and many more.

Commented By ->
Amit
Hibernate Question
What is the difference between Component mapping and association mapping
in Hibernate Mapping?

Answer
To the best of my understanding,
Component mapping between two class files, such as for example
company class file and department class file, can have a composition
relationship. So this means that class department should be mapped
within the company class definition. So this is the way component mapping
is done, such as shown below:

<class name="company" table="company">
  ....
  ....
  <component name="department" class="Department">
    ....
    ....
  <component>
<class>

One thing to note here that Department component mapping does not take
table name as attribute, thus department class is not mapped as an Entity
in component mapping. So attributes of company and department
class files should have corresponding column defined in the common table,
for example in this case it is company table.

As Department is not having any independent identity in database, so this
is not an Entity that can be deleted alone. If company Entity is deleted,
then corresponding Department will be deleted as well. Thus Object-oriented
composition relationship/notation among different objects can be achieved.

But in case of association mapping, both the objects will have different
class tags in Hibernate mapping file, and having different tables, and 
in this case these objects are having different identity and are Entities.

This is one of the different I can remember as of now, if anyone having
any comments on this, please write it here.




Commented By ->
sourav
Association Mapping is usually happen between parent-child related tables,where 
both the tables are dependent on each other with one-to-one or one-to-many or 
many-to-many relationship.
Please write your Comment on this Matter
(This will be visible if found suitable):
Name: *
Email (will not be displayed): *
Matter: *
10,40
Enter bigger number from above :*
Home > Hibernate Tutorial > Interview Questions > On Hibernate
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 *:
26,16
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.