Hibernate's primary feature is mapping from Java classes to database tables (and from Java data types to SQL data types). Hibernate also provides data query and retrieval facilities. Hibernate generates the SQL calls and relieves the developer from manual result set handling and object conversion, keeping the application portable to all SQL databases, with database portability delivered at very little performance overhead.
Hibernate provides transparent persistence for Plain Old Java Objects (POJOs). The only strict requirement for a persistent class is a no-argument constructor, not compulsorily public. (Proper behavior in some applications also requires special attention to the equals() and hashCode() methods.)
Hibernate provides a dirty checking feature that avoids unnecessary database write actions by performing SQL updates only on the modified fields of persistent objects.
Hibernate can be used both in standalone Java applications and in Java EE applications using servlets or EJB session beans.
11. What are the different levels of ORM quality?
There are four levels defined for ORM quality. i. Pure relational ii. Light object mapping iii. Medium object mapping iv. Full object mapping
12. What are the different methods of identifying an object?
There are three methods by which an object can be identified. i. Object identity ?Objects are identical if they reside in the same memory location in the JVM. This can be checked by using the = = operator. ii. Object equality ? Objects are equal if they have the same value, as defined by the equals( ) method. Classes that don?t explicitly override this method inherit the implementation defined by java.lang.Object, which compares object identity. iii. Database identity ? Objects stored in a relational database are identical if they represent the same row or, equivalently, share the same table and primary key value.
13. What are the Extension interfaces that are there in hibernate?
There are many extension interfaces provided by hibernate. ProxyFactory interface - used to create proxies ConnectionProvider interface ? used for JDBC connection management TransactionFactory interface ? Used for transaction management Transaction interface ? Used for transaction management TransactionManagementLookup interface ? Used in transaction management. Cahce interface ? provides caching techniques and strategies CacheProvider interface ? same as Cache interface ClassPersister interface ? provides ORM strategies IdentifierGenerator interface ? used for primary key generation Dialect abstract class ? provides SQL support
14. What do you create a SessionFactory?
Configuration cfg = new Configuration();
cfg.addResource("myinstance/MyConfig.hbm.xml");
cfg.setProperties( System.getProperties() );
SessionFactory sessions = cfg.buildSessionFactory();
First, we need to create an instance of Configuration and use that instance to refer to the
location of the configuration file. After configuring this instance is used to create the
SessionFactory by calling the method buildSessionFactory().
15. What does an ORM solution comprises of?
1? It should have an API for performing basic CRUD (Create, Read, Update, Delete) operations on objects of persistent classes 2? Should have a language or an API for specifying queries that refer to the classes and the properties of classes 3? An ability for specifying mapping metadata 4? It should have a technique for ORM implementation to interact with transactional objects to perform dirty checking, lazy association fetching, and other optimization functions
16. What does hibernate.properties file consist of?
This is a property file that should be placed in application class path. So when the Configuration object is created, hibernate is first initialized. At this moment the application will automatically detect and read this hibernate.properties file. hibernate.connection.datasource = java:/comp/env/jdbc/AuctionDB hibernate.transaction.factory_class = net.sf.hibernate.transaction.JTATransactionFactory hibernate.transaction.manager_lookup_class = net.sf.hibernate.transaction.JBossTransactionManagerLookup hibernate.dialect = net.sf.hibernate.dialect.PostgreSQLDialect
17. What is a hibernate xml mapping document and how does it look like?
In order to make most of the things work in hibernate, usually the information is provided in an xml document. This document is called as xml mapping document. The document defines, among other things, how properties of the user defined persistence classes? map to the columns of the relative tables in database.Everything should be included under tag. This is the main tag for an xml mapping document.
18. What is a meant by light object mapping?
The entities are represented as classes that are mapped manually to the relational tables. The code is hidden from the business logic using specific design patterns. This approach is successful for applications with a less number of entities, or applications with common, metadata-driven data models. This approach is most known to all.
19. What is a meant by medium object mapping?
The application is designed around an object model. The SQL code is generated at build time. And the associations between objects are supported by the persistence mechanism, and queries are specified using an object-oriented expression language. This is best suited for medium-sized applications with some complex transactions. Used when the mapping exceeds 25 different database products at a time.
20. What is a pure relational ORM?
The entire application, including the user interface, is designed around the relational model and SQL-based relational operations.