This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Is Meant By A Named Sql Query In Hibernate And How It’s Used? |
|
Answer» Named SQL QUERIES are those queries which are defined in mapping file and are called as required anywhere. Named SQL queries are those queries which are defined in mapping file and are called as required anywhere. |
|
| 2. |
What’s The Difference Between Load() And Get() Method In Hibernate? |
|
Answer» Load() methods RESULTS in an EXCEPTION if the required RECORDS isn’t found in the database while GET() method returns null when records against the id isn’t found in the database.
Load() methods results in an exception if the required records isn’t found in the database while get() method returns null when records against the id isn’t found in the database.
|
|
| 3. |
What’s The Use Of Version Property In Hibernate? |
|
Answer» Version property is used in HIBERNATE to know whether an OBJECT is in TRANSIENT STATE or in DETACHED state.
Version property is used in hibernate to know whether an object is in transient state or in detached state.
|
|
| 4. |
What Is Attribute Oriented Programming? |
|
Answer» In ATTRIBUTE oriented programming, a developer can ADD Meta data (attributes) in the JAVA source code to add more significance in the code. For Java (hibernate), attribute oriented programming is enabled by an ENGINE called XDoclet. In Attribute oriented programming, a developer can add Meta data (attributes) in the java source code to add more significance in the code. For Java (hibernate), attribute oriented programming is enabled by an engine called XDoclet. |
|
| 5. |
What’s The Use Of Session.lock() In Hibernate? |
|
Answer» session.lock() method of session class is used to REATTACH an object which has been detached earlier. This method of reattaching doesn’t CHECK for any data synchronization in DATABASE while reattaching the object and hence may lead to LACK of synchronization in data. session.lock() method of session class is used to reattach an object which has been detached earlier. This method of reattaching doesn’t check for any data synchronization in database while reattaching the object and hence may lead to lack of synchronization in data. |
|
| 6. |
Does Hibernate Support Polymorphism? |
|
Answer» Yes, HIBERNATE fully SUPPORTS polymorphism. Polymorphism QUERIES and polymorphism ASSOCIATIONS are supported in all mapping strategies of hibernate. Yes, hibernate fully supports polymorphism. Polymorphism queries and polymorphism associations are supported in all mapping strategies of hibernate. |
|
| 7. |
What The Three Inheritance Models Are Of Hibernate? |
|
Answer» HIBERNATE has FOLLOWING three INHERITANCE models: Hibernate has following three inheritance models: |
|
| 8. |
How Can We Map The Classes As Immutable? |
|
Answer» If we don’t want an application to UPDATE or delete OBJECTS of a class in HIBERNATE, we can MAKE the class as immutable by setting mutable=false If we don’t want an application to update or delete objects of a class in hibernate, we can make the class as immutable by setting mutable=false |
|
| 9. |
What’s General Hibernate Flow Using Rdbms? |
|
Answer» GENERAL hibernate FLOW INVOLVING RDBMS is as follows: General hibernate flow involving RDBMS is as follows: |
|
| 10. |
What Is Light Object Mapping? |
|
Answer» Light Object Mapping is ONE of the levels of ORM quality in which all entities are REPRESENTED as CLASSES and they are mapped manually. Light Object Mapping is one of the levels of ORM quality in which all entities are represented as classes and they are mapped manually. |
|
| 11. |
What’s Difference Between Managed Associations And Hibernate Associations? |
|
Answer» MANAGED ASSOCIATIONS relate to container MANAGEMENT persistence and are bi-directional while HIBERNATE associations are unidirectional. Managed associations relate to container management persistence and are bi-directional while hibernate associations are unidirectional. |
|
| 12. |
How Can We Bind Hibernate Session Factory To Jndi? |
|
Answer» Hibernate session FACTORY can be bound to JNDI by MAKING configuration CHANGES in hibernate.cfg file. Hibernate session factory can be bound to JNDI by making configuration changes in hibernate.cfg file. |
|
| 13. |
What’s The Role Of Jmx In Hibernate? |
|
Answer» Java Applications and components are managed in HIBERNATE by a standard API CALLED JMX API. JMX provides TOOLS for development of efficient and robust distributed, web based solutions. Java Applications and components are managed in hibernate by a standard API called JMX API. JMX provides tools for development of efficient and robust distributed, web based solutions. |
|
| 14. |
Which One Is The Default Transaction Factory In Hibernate? |
|
Answer» With HIBERNATE 3.2, DEFAULT TRANSACTION FACTORY is JDBCTransactionFactory. With hibernate 3.2, default transaction factory is JDBCTransactionFactory. |
|
| 15. |
What Is Orm Metadata? |
|
Answer» All the mapping between classes and tables, PROPERTIES and COLUMNS, JAVA types and SQL types ETC is defined in ORM metadata. All the mapping between classes and tables, properties and columns, Java types and SQL types etc is defined in ORM metadata. |
|
| 16. |
What Are Different Ways To Disable Hibernate Second Level Cache? |
|
Answer» HIBERNATE second level cache can be disabled using any of the FOLLOWING ways: Hibernate second level cache can be disabled using any of the following ways: |
|
| 17. |
How Can We Reattach Any Detached Objects In Hibernate? |
|
Answer» Objects which have been detached and are no LONGER associated with any PERSISTENT ENTITIES can be reattached by calling SESSION.merge() METHOD of session class. Objects which have been detached and are no longer associated with any persistent entities can be reattached by calling session.merge() method of session class. |
|
| 18. |
How Primary Key Is Created By Using Hibernate? |
|
Answer» Database primary key is specified in the configuration FILE hbm.xml. GENERATOR can also be used to SPECIFY how primary key is being created in the database. Database primary key is specified in the configuration file hbm.xml. Generator can also be used to specify how primary key is being created in the database. |
|
| 19. |
In How Many Ways, Objects Can Be Fetched From Database In Hibernate? |
|
Answer» Hibernate provides FOLLOWING FOUR WAYS to fetch OBJECTS from DATABASE: Hibernate provides following four ways to fetch objects from database: |
|
| 20. |
What’s The Usage Of Hibernate Qbc Api? |
|
Answer» Hibernate Query By CRITERIA (QBC) API is used to create queries by MANIPULATION of criteria OBJECTS at RUNTIME. Hibernate Query By Criteria (QBC) API is used to create queries by manipulation of criteria objects at runtime. |
|
| 21. |
What Are The Two Mapping Associations Used In Hibernate? |
|
Answer» In HIBERNATE; we have FOLLOWING two TYPES of MAPPING ASSOCIATIONS between entities:
In hibernate; we have following two types of mapping associations between entities:
|
|
| 22. |
What Is The Default Cache Service Of Hibernate? |
|
Answer» HIBERNATE SUPPORTS MULTIPLE cache services like EHCache, OSCache, SWARMCache and TreeCache and DEFAULT cache service of hibernate is EHCache. Hibernate supports multiple cache services like EHCache, OSCache, SWARMCache and TreeCache and default cache service of hibernate is EHCache. |
|
| 23. |
What The Two Methods Are Of Hibernate Configuration? |
|
Answer» We can use any of the following two METHODS of HIBERNATE configuration:
We can use any of the following two methods of hibernate configuration:
|
|
| 24. |
What’s Transaction Management In Hibernate? How It Works? |
|
Answer» Transaction management is the process of managing a set of statements or COMMANDS. In hibernate; transaction management is DONE by transaction interface as SHOWN in below code:
Transaction management is the process of managing a set of statements or commands. In hibernate; transaction management is done by transaction interface as shown in below code:
|
|
| 25. |
What The Four Orm Levels Are In Hibernate? |
|
Answer» FOLLOWING are the four ORM LEVELS in hibernate: Following are the four ORM levels in hibernate: |
|
| 26. |
When An Instance Goes In Detached State In Hibernate? |
|
Answer» When an instance was earlier associated with some PERSISTENT CONTEXT (e.g. a table) and is no LONGER associated, it’s called to be in DETACHED state. When an instance was earlier associated with some persistent context (e.g. a table) and is no longer associated, it’s called to be in detached state. |
|
| 27. |
What’s The Usage Of Callback Interfaces In Hibernate? |
|
Answer» CALLBACK INTERFACES of hibernate are useful in receiving event notifications from objects. For example, when an object is loaded or deleted, an event is GENERATED and NOTIFICATION is sent using callback interfaces. Callback interfaces of hibernate are useful in receiving event notifications from objects. For example, when an object is loaded or deleted, an event is generated and notification is sent using callback interfaces. |
|
| 28. |
How Can We Reduce Database Write Action Times In Hibernate? |
|
Answer» HIBERNATE provides dirty checking feature which can be USED to reduce database WRITE times. Dirty checking feature of hibernate UPDATES only those fields which require a CHANGE while keeps others unchanged.
Hibernate provides dirty checking feature which can be used to reduce database write times. Dirty checking feature of hibernate updates only those fields which require a change while keeps others unchanged.
|
|
| 29. |
What Is Transient Instance State In Hibernate? |
|
Answer» If an instance is not ASSOCIATED with any PERSISTENT context and also, it has NEVER been associated with any persistent context, then it’s said to be in TRANSIENT STATE. If an instance is not associated with any persistent context and also, it has never been associated with any persistent context, then it’s said to be in transient state. |
|
| 30. |
How Can We Get Hibernate Statistics? |
|
Answer» We can get hibernate STATISTICS USING getStatistics() method of SessionFactory CLASS as SHOWN below: We can get hibernate statistics using getStatistics() method of SessionFactory class as shown below: |
|
| 31. |
What The Benefits Are Of Hibernate Over Jdbc? |
|
Answer» a.Hibernate can be used seamlessly with any TYPE of database as its database independent while in CASE of JDBC, developer has to write database specific queries. a.Hibernate can be used seamlessly with any type of database as its database independent while in case of JDBC, developer has to write database specific queries. |
|
| 32. |
What’s The Difference Between Session.save() And Session.saveorupdate() Methods In Hibernate? |
|
Answer» Sessionsave() method SAVES a RECORD only if it’s unique with RESPECT to its primary key and will FAIL to insert if primary key already EXISTS in the table. Sessionsave() method saves a record only if it’s unique with respect to its primary key and will fail to insert if primary key already exists in the table. |
|
| 33. |
What Are The Two Types Of Collections In Hibernate? |
|
Answer» Following are the TWO TYPES of COLLECTIONS in hibernate:
Following are the two types of collections in hibernate:
|
|
| 34. |
How Can We See Hibernate Generated Sql On Console? |
|
Answer» We need to add following in HIBERNATE configuration file to ENABLE viewing SQL on the console for debugging PURPOSES: We need to add following in hibernate configuration file to enable viewing SQL on the console for debugging purposes: |
|
| 35. |
What Are The Benefits Of Using Hibernate Template? |
|
Answer» Following are some key BENEFITS of USING Hibernate TEMPLATE: Following are some key benefits of using Hibernate template: |
|
| 36. |
What Is Criteria Api? |
|
Answer» CRITERIA is a SIMPLE YET powerful API of hibernate which is USED to retrieve entities through criteria OBJECT composition. Criteria is a simple yet powerful API of hibernate which is used to retrieve entities through criteria object composition. |
|
| 37. |
How Can We Invoke Stored Procedures In Hibernate? |
|
Answer» In HIBERNATE we can EXECUTE STORED procedures using code as below: In hibernate we can execute stored procedures using code as below: |
|
| 38. |
What’s Hql? |
|
Answer» HQL is the QUERY language USED in HIBERNATE which is an EXTENSION of SQL. HQL is very efficient, simple and FLEXIBLE query language to do various type of operations on relational database without writing complex database queries. HQL is the query language used in Hibernate which is an extension of SQL. HQL is very efficient, simple and flexible query language to do various type of operations on relational database without writing complex database queries. |
|
| 39. |
What Are Pojos And What’s Their Significance? |
|
Answer» POJOS( Plain Old Java Objects) are java BEANS with proper getter and setter methods for each and every properties. POJOs( Plain Old Java Objects) are java beans with proper getter and setter methods for each and every properties. |
|
| 40. |
How Do We Create Session Factory In Hibernate? |
|
Answer» To CREATE a session factory in hibernate, an OBJECT of CONFIGURATION is CREATED first which refers to the path of configuration file and then for that configuration, session factory is created as given in the EXAMPLE below:
To create a session factory in hibernate, an object of configuration is created first which refers to the path of configuration file and then for that configuration, session factory is created as given in the example below: |
|
| 41. |
Should All The Mapping Files Of Hibernate Have .hbm.xml Extension To Work Properly? |
|
Answer» No, having .hbm.xml extension is a convention and not a REQUIREMENT for HIBERNATE MAPPING FILE names. We can have any extension for these mapping files. No, having .hbm.xml extension is a convention and not a requirement for hibernate mapping file names. We can have any extension for these mapping files. |
|
| 42. |
How Can We Use New Custom Interfaces To Enhance Functionality Of Built-in Interfaces Of Hibernate? |
|
Answer» We can use EXTENSION interfaces in ORDER to add any REQUIRED FUNCTIONALITY which isn’t SUPPORTED by built-in interfaces. We can use extension interfaces in order to add any required functionality which isn’t supported by built-in interfaces. |
|
| 43. |
What’s The Usage Of Configuration Interface In Hibernate? |
|
Answer» Configuration interface of HIBERNATE FRAMEWORK is USED to configure hibernate. It’s ALSO used to bootstrap hibernate. Mapping documents of hibernate are LOCATED using this interface. Configuration interface of hibernate framework is used to configure hibernate. It’s also used to bootstrap hibernate. Mapping documents of hibernate are located using this interface. |
|
| 44. |
What’s Hibernate? |
|
Answer» HIBERNATE is a POPULAR framework of JAVA which allows an efficient Object Relational MAPPING using configuration FILES in XML format. After java objects mapping to database tables, database is used and handled using Java objects without writing complex database queries. Hibernate is a popular framework of Java which allows an efficient Object Relational mapping using configuration files in XML format. After java objects mapping to database tables, database is used and handled using Java objects without writing complex database queries. |
|