Advertisement :
   Log In    OR    Register  
  Topics :  
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 :
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...

Tags/Keywords : On-Hibernate - Interview-Questions - Hibernate-Tutorial Example
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.
Are you interested in solving a very interesting Technology Stack while Playing this Game          

Please write your Comment on this Matter
(This will be visible if found suitable):
Name: *
Email (will not be displayed): *
Matter: *
3,30
Enter bigger number from above :*
Home >>> Hibernate Tutorial >>> Interview Questions >>> On Hibernate
Visitor/User referred related external URL:
(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 *:
40,13
Enter bigger number from above : *

Please log in to add or reply to any matter<- 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.