What are the various built-in-mapping types available in Hibernate?
Hibernate built-in mapping types usually share the name of the Java type they map; however, there may be more than one Hibernate mapping type for a partucular Java type. The various built-in-mapping types available in Hibernate are:
* Java primitive mapping types
* Date and time mapping types
* Large object mapping types
* Various JDK mapping typesReply
What are the various transaction isolation isssues in Hibernate?
The ANSI SQL standard defines the standart transaction isolation levels in terms of which of these phenomenon are permissible:
* Last update
* Dirty read
* Unrepeatable read
* Second lost updates problem
* Phantom readReply
What are the Collection types in Hibernate ?
The types of Collection in Hibernate:
What are the various fetching strategies from the database in Hibernate?
Hibernate allows you to choose among four fetching strategies for any association, in association and at runtime:
* Immediate fetching.
* Lazy fetching.
* Eager fatching.
* Batch fetching.Reply
What are the various ways to fetch objects from database in Hibernate?
Hibernate provides the following ways to get objects out of the database:
* Navigating the object graph, starting from an already loaded object, by accessing the associated objects through property accessor methods.
* Retrieving by Identifier.
* Using the Hibernate Query Language (HQL).
* Using the Hibernate Criteria API.
* Using native SQL Queries.Reply
What is the difference between beans and Hibernate?
Hibernate uses POJO classes for handling persistence, these classes need to adhere normal bean writing. Beans are at form (view) level and Hibernate are at database level.
JavaBeans are simple reusable component whereas hibernate are supports for the JavaBean object persistency.Reply
How will you create a primary key using Hibernate?
The id field in hbm.xml file is used to specify the primary key in database. We can also use generator to specify the way primary key is generated to the database.
<id name="StudentId" type="string" >
<column name="columnId" length="30"/>
Here Id ="StudentId" act as primary key.Reply
What is the main advantage of using Hibernate than sql?
The main advantage of using Hibernate over sql is that Hibernate avoids writing huge queries. Because most of the work is taken care by mapping and also criteria class is very useful for complex joins. We can also avoid JDBC API by using Hibernate.
What is the difference between sorted and order collection in Hibernate?
A sorted ordered collection is stored in memory using Java Comparetor, whereas ordered collection is stored at the database level using orderby clause.Reply
What are the general considerations or best practices for defining your Hibernate persistent classes?
The general considerations or best practices for defining your Hibernate persistent classes are:
* You must have defined no-argument constructor, getters and setters method.
* Implement the equals() and hashCode() methods based on your business key and it is important not to use the id field in your equals() and hashCode() definition if the id field is a surrogate key.
* Implement the Serializable interface.
* The persistent class should not be final.
* Use XDoclet tags for generating your *.hbm.xml files or Annotations.Reply