{
"iq":[{"id":"1",
"q":"What is Hibernate?",
"answer":"Hibernate is a popular framework of Java which allows an efficient Object\n\nRelational 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. "
},
{"id":"2",
"q":"What is ORM? ",
"answer":"ORM (Object Relational Mapping) is the fundamentalconcept of Hibernate framework which maps database tables with Java Objects and then provides various API’s to perform different types of operations on the data tables. "
},
{"id":"3",
"q":"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."
},
{"id":"4",
"q":"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. "
},
{"id":"5",
"q":"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."
},
{"id":"6",
"q":"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:\n\nConfiguration config = new Configuration();\n\nconfig.addResource("myinstance/configuration.hbm.xml");\n\nconfig.setProperties( System.getProperties() );\n\nSessionFactory sessions = config.buildSessionFactory();"
},
{"id":"7",
"q":"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.Use of POJOs instead of simple java classes results in an efficient and well constructed code. "
},
{"id":"8",
"q":"What’s HQL?",
"answer":"HQL is the query language used in Hibernate which is an extension of SQL.\n\nHQL is very efficient,simple and flexible query language to do various type of operations on relational database without writing complex database queries."
},
{"id":"9",
"q":"What is Java Persistence API (JPA)? ",
"answer":"ava Persistence API (JPA) provides specification for managing the relational data in applications. Current JPA version 2.1 was started in July 2011 as JSR 338. JPA 2.1 was approved as final on 22 May 2013.\n\nJPA specifications is defined with annotations in javax.persistence package. Using JPA annotation helps us in writing implementation independent code."
},
{"id":"10",
"q":"What does ORM consists of ?",
"answer":"An ORM solution consists of the followig four pieces:\n\nAPI for performing basic CRUD operations\n\nAPI to express queries refering to classes\n\nFacilities to specify metadata\n\nOptimization facilities : dirty checking,lazy associations fetching"
},
{"id":"11",
"q":"What Does Hibernate Simplify?",
"answer":"Hibernate simplifies:\n\nSaving and retrieving your domain objects\n\nMaking database column and table name changes\n\nCentralizing pre save and post retrieve logic\n\nComplex joins for retrieving related items\n\nSchema creation from object model"
},
{"id":"12",
"q":"What are the most common methods of Hibernate configuration?",
"answer":"The most common methods of Hibernate configuration are:\n\nProgrammatic configuration\n\nXML configuration (hibernate.cfg.xml)"
},
{"id":"13",
"q":"What are the Core interfaces are of Hibernate framework?",
"answer":" The five core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions.\n\nSession interface\n\nSessionFactory interface\n\nConfiguration interface\n\nTransaction interface\n\nQuery and Criteria interfaces"
},
{"id":"14",
"q":"What role does the Session interface play in Hibernate?",
"answer":"The Session interface is the primary interface used by Hibernate applications. It is a single-threaded, short-lived object representing a conversation between the application and the persistent store. It allows you to create query objects to retrieve persistent objects.\n\nSession session = sessionFactory.openSession();\n\nSession interface role:\n\nWraps a JDBC connection\n\nFactory for Transaction\n\nHolds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier"
},
{"id":"15",
"q":" What role does the SessionFactory interface play in Hibernate?",
"answer":" The application obtains Session instances from a SessionFactory.There is typically a single SessionFactory for the whole applicationan treated during application initialization.\n\nThe SessionFactory caches generate SQL statements and other mapping metadata that Hibernate uses at runtime.It also holds cached data that has been read in one unit of work and may be reused in a future unit of work\n\nSessionFactory sessionFactory = configuration.buildSessionFactory(); "
},
{"id":"16",
"q":" What is the general flow of Hibernate communication with RDBMS?",
"answer":"The general flow of Hibernate communication with RDBMS is :\n\nLoad the Hibernate configuration file and create configuration object. It will automatically load all hbm mapping files\n\nCreate session factory from configuration object\n\nGet one session from this session factory\n\nCreate HQL Query\n\nExecute query to get list containing Java objects "
},
{"id":"17",
"q":"What is the difference between and merge and update ?",
"answer":"Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session. "
},
{"id":"18",
"q":"Define cascade and inverse option in one-many mapping?",
"answer":"cascade - enable operations to cascade to child entities.\n\ncascade=\"all|none|save-update|delete|all-delete-orphan\"\n\ninverse - mark this collection as the \"inverse\" end of a bidirectional association.\n\ninverse=\"true|false\"Essentially\"inverse\" indicates which end of a relationship should be ignored, so when persisting a parent who has a collection of children, should you ask the parent for its list of children, or ask the children who the parents are?"
},
{"id":"19",
"q":"Explain Criteria API ",
"answer":" ICriteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like \"search\" screens where there is a variable number of conditions to be placed upon the result set.\n\nExample :\n\nList employees = session.createCriteria(Employee.class)\n\n.add(Restrictions.like(\"name\", \"a%\") )\n\n.add(Restrictions.like(\"address\", \"Boston\"))\n\n.addOrder(Order.asc(\"name\") )\n\n.list(); "
},
{"id":"20",
"q":"Define HibernateTemplate?",
"answer":"org.springframework.orm.hibernate.HibernateTemplate is a helper class which provides different methods for querying/retrieving data from the database. It also converts checked HibernateExceptions into unchecked DataAccessExceptions. "
},
{"id":"21",
"q":"What are the benefits does HibernateTemplate provide?",
"answer":"The benefits of HibernateTemplate are :\n\nHibernateTemplate, a Spring Template class simplifies interactions with Hibernate Session.\n\nCommon functions are simplified to single method calls.\n\nSessions are automatically closed.\n\nExceptions are automatically caught and converted to runtime exceptions."
},
{"id":"22",
"q":"How do you switch between relational databases without code changes? ",
"answer":" Using Hibernate SQL Dialects , we can switch databases.Hibernate will generate appropriate hql queries based on the dialect defined.; "
},
{"id":"23",
"q":"If you want to see the Hibernate generated SQL statements on console, what should we do?",
"answer":" In Hibernate configuration file set as follows:\n\n<property name=\"show_sql\">true</property>"
},{"id":"24",
"q":" What are derived properties? ",
"answer":"The properties that are not mapped to a column, but calculated at runtime by evaluation of an expression are called derived properties.\n\nThe expression can be defined using the formula attribute of the element."
},{"id":"25",
"q":"What is component mapping in Hibernate? ",
"answer":"A component is an object saved as a value, not as a reference\n\nA component can be saved directly without needing to declare interfaces or identifier properties\n\nRequired to define an empty constructor\n\nShared references not supported"
},{"id":"26",
"q":"What are the Collection types in Hibernate ?",
"answer":"Bag\n\nSet\n\nList\n\nArray\n\nMap"
},{"id":"27",
"q":" What are the ways to express joins in HQL?",
"answer":"HQL provides four ways of expressing (inner and outer) joins:-\n\nAn implicit association join\n\nAn ordinary join in the FROM clause\n\nA fetch join in the FROM clause.\n\nA theta-style join in the WHERE clause."
},{"id":"28",
"q":"What is Hibernate proxy? ",
"answer":"The proxy attribute enables lazy initialization of persistent instances of the class. Hibernate will initially return CGLIB proxies which implement the named interface. The actual persistent object will be loaded when a method of the proxy is invoked."
},{"id":"29",
"q":"How can Hibernate be configured to access an instance variable directly and not through a setter method ?",
"answer":"By mapping the property with access=\"field\" in Hibernate metadata. This forces hibernate to bypass the setter method and access the instance variable directly while initializing a newly loaded object."
},{"id":"30",
"q":" How can a whole class be mapped as immutable? ",
"answer":"Mark the class as mutable=\"false\" (Default is true),. This specifies that instances of the class are (not) mutable. Immutable classes, may not be updated or deleted by the application."
},{"id":"31",
"q":"What is the use of dynamic-insert and dynamic-update attributes in a class mapping? ",
"answer":"Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like \"search\" screens where there is a variable number of conditions to be placed upon the result set.\n\ndynamic-update (defaults to false): Specifies that UPDATE SQL should be generated at runtime and contain only those columns whose values have changed\n\ndynamic-insert (defaults to false): Specifies that INSERT SQL should be generated at runtime and contain only the columns whose values are not null."
},{"id":"32",
"q":"What do you mean by fetching strategy ?",
"answer":"\n\nA fetching strategy is the strategy Hibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query."
},{"id":"33",
"q":" What is automatic dirty checking?",
"answer":"Automatic dirty checking is a feature that saves us the effort of explicitly asking Hibernate to update the database when we modify the state of an object inside a transaction. "
},{"id":"34",
"q":" What is transactional write-behind?",
"answer":"Hibernate uses a sophisticated algorithm to determine an efficient ordering that avoids database foreign key constraint violations but is still sufficiently predictable to the user. This feature is called transactional write-behind. "
},
{"id":"35",
"q":"What are Callback interfaces?",
"answer":"Callback interfaces allow the application to receive a notification when something interesting happens to an object—for example, when an object is loaded, saved, or deleted. Hibernate applications don't need to implement these callbacks, but they're useful for implementing certain kinds of generic functionality."
},{"id":"36",
"q":" What are the types of Hibernate instance states ?",
"answer":"Three types of instance states:\n\nTransient -The instance is not associated with any persistence context\n\nPersistent -The instance is associated with a persistence context\n\nDetached -The instance was associated with a persistence context which has been closed – currently not associated "
},{"id":"37",
"q":"What are the types of inheritance models in Hibernate?",
"answer":"There are three types of inheritance models in Hibernate:\n\nTable per class hierarchy\n\nTable per subclass\n\nTable per concrete class "
},{"id":"38",
"q":"What is criteria API?",
"answer":"Criteria is a simple yet powerful API of hibernate which is used to retrieve entities through criteria object composition."
},{"id":"39",
"q":" What are the benefits of using Hibernate template? ",
"answer":"a. Session closing is automated.\n\nb. Interaction with hibernate session is simplified.\n\nc. Exception handling is automated."
},{"id":"40",
"q":" 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:\n\n[xml]\n\n<property name=”show_sql”>true</property>\n\n[/xml]"
},{"id":"41",
"q":"What is a meant by light object mapping? ",
"answer":"The entities are represented as classes that are mapped manually to therelational 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."
},{"id":"42",
"q":" What is hibernate tuning ? ",
"answer":"The key to obtain better performance in any hibernate application is to employ SQL Optimization, session management, and Data caching."
},{"id":"43",
"q":"Explain about addClass function?",
"answer":" This function translates a Java class name into file name. This translated file name is then loaded as an input stream from the Java class loader. This addclass function is important if you want efficient usage of classes in your code."
},{"id":"44",
"q":"Explain State some advantages of hibernate?",
"answer":"Mapping of one POJO table to one table is not required in hibernate.It supports inheritance relationships and is generally a fast tool. Portability is necessary the greater benefit from hibernate. POJOs can be used in other applications where they are applicable."
},{"id":"45",
"q":" What are the Collection types in Hibernate ?",
"answer":"Bag ,Set, List, Array, Map"
},{"id":"46",
"q":"What are the ways to express joins in HQL?",
"answer":"HQL provides four ways of expressing (inner and outer) joins:-\n\nAn implicit association join An ordinary join in the FROM clause A fetch join in the FROM clause. A theta-style join in the WHERE clause. "
},{"id":"47",
"q":" Define cascade and inverse option in one-many mapping?",
"answer":"Storing the user’s information within the WEB SERVER memory is called as Server Side State Management. "
},{"id":"48",
"q":" What is a session? How many types of sessions? What is a session? How many types of sessions? ",
"answer":"Session is a temporary variable which will be used to maintain the user information. Based on the locations, sessions are of4 types: 1. Inproc session 2. State server session 3. Sql server session 4. Custom session "
},{"id":"49",
"q":" What is the difference between and merge and update ? ",
"answer":"Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session. "
},{"id":"50",
"q":"What the four ORM levels are in hibernate? ",
"answer":"a. Pure Relational\n\nb. Light Object Mapping\n\nc. Medium Object Mapping\n\nd. Full Object Mapping"
},{"id":"51",
"q":" What the two methods are of hibernate configuration? ",
"answer":"We can use any of the following two methods of hibernate configuration:\n\na. XML based configuration ( using hibernate.cfg.xml file)\n\nb. Programmatic configuration ( Using code logic) "
},
{"id":"52",
"q":"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. "
},{"id":"53",
"q":"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. "
},{"id":"54",
"q":" Which one is the default transaction factory in hibernate?",
"answer":"With hibernate 3.2, default transaction factory is JDBCTransactionFactory."
},{"id":"55",
"q":"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."
},{"id":"56",
"q":"What different fetching strategies are of hibernate?",
"answer":"1. Join Fetching\n\n2. Batch Fetching\n\n3. Select Fetching\n\n4. Sub-select Fetching"
},{"id":"57",
"q":"What are derived properties in hibernate? ",
"answer":"Derived properties are those properties which are not mapped to any columns of a database table. Such properties are calculated at runtime by evaluation of any expressions."
},{"id":"58",
"q":"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."
},{"id":"59",
"q":" Does hibernate support polymorphism? ",
"answer":"Yes, hibernate fully supports polymorphism. Polymorphism queries and polymorphism associations are supported in all mapping strategies of hibernate."
},{"id":"60",
"q":"What the three inheritance models are of hibernate? ",
"answer":"Hibernate has following three inheritance models:\n\na. Tables Per Concrete Class\n\nb. Table per class hierarchy\n\nc. Table per sub-class"
}
]
}
"iq":[{"id":"1",
"q":"What is Hibernate?",
"answer":"Hibernate is a popular framework of Java which allows an efficient Object\n\nRelational 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. "
},
{"id":"2",
"q":"What is ORM? ",
"answer":"ORM (Object Relational Mapping) is the fundamentalconcept of Hibernate framework which maps database tables with Java Objects and then provides various API’s to perform different types of operations on the data tables. "
},
{"id":"3",
"q":"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."
},
{"id":"4",
"q":"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. "
},
{"id":"5",
"q":"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."
},
{"id":"6",
"q":"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:\n\nConfiguration config = new Configuration();\n\nconfig.addResource(&amp;quot;myinstance/configuration.hbm.xml&amp;quot;);\n\nconfig.setProperties( System.getProperties() );\n\nSessionFactory sessions = config.buildSessionFactory();"
},
{"id":"7",
"q":"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.Use of POJOs instead of simple java classes results in an efficient and well constructed code. "
},
{"id":"8",
"q":"What’s HQL?",
"answer":"HQL is the query language used in Hibernate which is an extension of SQL.\n\nHQL is very efficient,simple and flexible query language to do various type of operations on relational database without writing complex database queries."
},
{"id":"9",
"q":"What is Java Persistence API (JPA)? ",
"answer":"ava Persistence API (JPA) provides specification for managing the relational data in applications. Current JPA version 2.1 was started in July 2011 as JSR 338. JPA 2.1 was approved as final on 22 May 2013.\n\nJPA specifications is defined with annotations in javax.persistence package. Using JPA annotation helps us in writing implementation independent code."
},
{"id":"10",
"q":"What does ORM consists of ?",
"answer":"An ORM solution consists of the followig four pieces:\n\nAPI for performing basic CRUD operations\n\nAPI to express queries refering to classes\n\nFacilities to specify metadata\n\nOptimization facilities : dirty checking,lazy associations fetching"
},
{"id":"11",
"q":"What Does Hibernate Simplify?",
"answer":"Hibernate simplifies:\n\nSaving and retrieving your domain objects\n\nMaking database column and table name changes\n\nCentralizing pre save and post retrieve logic\n\nComplex joins for retrieving related items\n\nSchema creation from object model"
},
{"id":"12",
"q":"What are the most common methods of Hibernate configuration?",
"answer":"The most common methods of Hibernate configuration are:\n\nProgrammatic configuration\n\nXML configuration (hibernate.cfg.xml)"
},
{"id":"13",
"q":"What are the Core interfaces are of Hibernate framework?",
"answer":" The five core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions.\n\nSession interface\n\nSessionFactory interface\n\nConfiguration interface\n\nTransaction interface\n\nQuery and Criteria interfaces"
},
{"id":"14",
"q":"What role does the Session interface play in Hibernate?",
"answer":"The Session interface is the primary interface used by Hibernate applications. It is a single-threaded, short-lived object representing a conversation between the application and the persistent store. It allows you to create query objects to retrieve persistent objects.\n\nSession session = sessionFactory.openSession();\n\nSession interface role:\n\nWraps a JDBC connection\n\nFactory for Transaction\n\nHolds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier"
},
{"id":"15",
"q":" What role does the SessionFactory interface play in Hibernate?",
"answer":" The application obtains Session instances from a SessionFactory.There is typically a single SessionFactory for the whole applicationan treated during application initialization.\n\nThe SessionFactory caches generate SQL statements and other mapping metadata that Hibernate uses at runtime.It also holds cached data that has been read in one unit of work and may be reused in a future unit of work\n\nSessionFactory sessionFactory = configuration.buildSessionFactory(); "
},
{"id":"16",
"q":" What is the general flow of Hibernate communication with RDBMS?",
"answer":"The general flow of Hibernate communication with RDBMS is :\n\nLoad the Hibernate configuration file and create configuration object. It will automatically load all hbm mapping files\n\nCreate session factory from configuration object\n\nGet one session from this session factory\n\nCreate HQL Query\n\nExecute query to get list containing Java objects "
},
{"id":"17",
"q":"What is the difference between and merge and update ?",
"answer":"Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session. "
},
{"id":"18",
"q":"Define cascade and inverse option in one-many mapping?",
"answer":"cascade - enable operations to cascade to child entities.\n\ncascade=\"all|none|save-update|delete|all-delete-orphan\"\n\ninverse - mark this collection as the \"inverse\" end of a bidirectional association.\n\ninverse=\"true|false\"Essentially\"inverse\" indicates which end of a relationship should be ignored, so when persisting a parent who has a collection of children, should you ask the parent for its list of children, or ask the children who the parents are?"
},
{"id":"19",
"q":"Explain Criteria API ",
"answer":" ICriteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like \"search\" screens where there is a variable number of conditions to be placed upon the result set.\n\nExample :\n\nList employees = session.createCriteria(Employee.class)\n\n.add(Restrictions.like(\"name\", \"a%\") )\n\n.add(Restrictions.like(\"address\", \"Boston\"))\n\n.addOrder(Order.asc(\"name\") )\n\n.list(); "
},
{"id":"20",
"q":"Define HibernateTemplate?",
"answer":"org.springframework.orm.hibernate.HibernateTemplate is a helper class which provides different methods for querying/retrieving data from the database. It also converts checked HibernateExceptions into unchecked DataAccessExceptions. "
},
{"id":"21",
"q":"What are the benefits does HibernateTemplate provide?",
"answer":"The benefits of HibernateTemplate are :\n\nHibernateTemplate, a Spring Template class simplifies interactions with Hibernate Session.\n\nCommon functions are simplified to single method calls.\n\nSessions are automatically closed.\n\nExceptions are automatically caught and converted to runtime exceptions."
},
{"id":"22",
"q":"How do you switch between relational databases without code changes? ",
"answer":" Using Hibernate SQL Dialects , we can switch databases.Hibernate will generate appropriate hql queries based on the dialect defined.; "
},
{"id":"23",
"q":"If you want to see the Hibernate generated SQL statements on console, what should we do?",
"answer":" In Hibernate configuration file set as follows:\n\n<property name=\"show_sql\">true</property>"
},{"id":"24",
"q":" What are derived properties? ",
"answer":"The properties that are not mapped to a column, but calculated at runtime by evaluation of an expression are called derived properties.\n\nThe expression can be defined using the formula attribute of the element."
},{"id":"25",
"q":"What is component mapping in Hibernate? ",
"answer":"A component is an object saved as a value, not as a reference\n\nA component can be saved directly without needing to declare interfaces or identifier properties\n\nRequired to define an empty constructor\n\nShared references not supported"
},{"id":"26",
"q":"What are the Collection types in Hibernate ?",
"answer":"Bag\n\nSet\n\nList\n\nArray\n\nMap"
},{"id":"27",
"q":" What are the ways to express joins in HQL?",
"answer":"HQL provides four ways of expressing (inner and outer) joins:-\n\nAn implicit association join\n\nAn ordinary join in the FROM clause\n\nA fetch join in the FROM clause.\n\nA theta-style join in the WHERE clause."
},{"id":"28",
"q":"What is Hibernate proxy? ",
"answer":"The proxy attribute enables lazy initialization of persistent instances of the class. Hibernate will initially return CGLIB proxies which implement the named interface. The actual persistent object will be loaded when a method of the proxy is invoked."
},{"id":"29",
"q":"How can Hibernate be configured to access an instance variable directly and not through a setter method ?",
"answer":"By mapping the property with access=\"field\" in Hibernate metadata. This forces hibernate to bypass the setter method and access the instance variable directly while initializing a newly loaded object."
},{"id":"30",
"q":" How can a whole class be mapped as immutable? ",
"answer":"Mark the class as mutable=\"false\" (Default is true),. This specifies that instances of the class are (not) mutable. Immutable classes, may not be updated or deleted by the application."
},{"id":"31",
"q":"What is the use of dynamic-insert and dynamic-update attributes in a class mapping? ",
"answer":"Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like \"search\" screens where there is a variable number of conditions to be placed upon the result set.\n\ndynamic-update (defaults to false): Specifies that UPDATE SQL should be generated at runtime and contain only those columns whose values have changed\n\ndynamic-insert (defaults to false): Specifies that INSERT SQL should be generated at runtime and contain only the columns whose values are not null."
},{"id":"32",
"q":"What do you mean by fetching strategy ?",
"answer":"\n\nA fetching strategy is the strategy Hibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query."
},{"id":"33",
"q":" What is automatic dirty checking?",
"answer":"Automatic dirty checking is a feature that saves us the effort of explicitly asking Hibernate to update the database when we modify the state of an object inside a transaction. "
},{"id":"34",
"q":" What is transactional write-behind?",
"answer":"Hibernate uses a sophisticated algorithm to determine an efficient ordering that avoids database foreign key constraint violations but is still sufficiently predictable to the user. This feature is called transactional write-behind. "
},
{"id":"35",
"q":"What are Callback interfaces?",
"answer":"Callback interfaces allow the application to receive a notification when something interesting happens to an object—for example, when an object is loaded, saved, or deleted. Hibernate applications don't need to implement these callbacks, but they're useful for implementing certain kinds of generic functionality."
},{"id":"36",
"q":" What are the types of Hibernate instance states ?",
"answer":"Three types of instance states:\n\nTransient -The instance is not associated with any persistence context\n\nPersistent -The instance is associated with a persistence context\n\nDetached -The instance was associated with a persistence context which has been closed – currently not associated "
},{"id":"37",
"q":"What are the types of inheritance models in Hibernate?",
"answer":"There are three types of inheritance models in Hibernate:\n\nTable per class hierarchy\n\nTable per subclass\n\nTable per concrete class "
},{"id":"38",
"q":"What is criteria API?",
"answer":"Criteria is a simple yet powerful API of hibernate which is used to retrieve entities through criteria object composition."
},{"id":"39",
"q":" What are the benefits of using Hibernate template? ",
"answer":"a. Session closing is automated.\n\nb. Interaction with hibernate session is simplified.\n\nc. Exception handling is automated."
},{"id":"40",
"q":" 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:\n\n[xml]\n\n<property name=”show_sql”>true</property>\n\n[/xml]"
},{"id":"41",
"q":"What is a meant by light object mapping? ",
"answer":"The entities are represented as classes that are mapped manually to therelational 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."
},{"id":"42",
"q":" What is hibernate tuning ? ",
"answer":"The key to obtain better performance in any hibernate application is to employ SQL Optimization, session management, and Data caching."
},{"id":"43",
"q":"Explain about addClass function?",
"answer":" This function translates a Java class name into file name. This translated file name is then loaded as an input stream from the Java class loader. This addclass function is important if you want efficient usage of classes in your code."
},{"id":"44",
"q":"Explain State some advantages of hibernate?",
"answer":"Mapping of one POJO table to one table is not required in hibernate.It supports inheritance relationships and is generally a fast tool. Portability is necessary the greater benefit from hibernate. POJOs can be used in other applications where they are applicable."
},{"id":"45",
"q":" What are the Collection types in Hibernate ?",
"answer":"Bag ,Set, List, Array, Map"
},{"id":"46",
"q":"What are the ways to express joins in HQL?",
"answer":"HQL provides four ways of expressing (inner and outer) joins:-\n\nAn implicit association join An ordinary join in the FROM clause A fetch join in the FROM clause. A theta-style join in the WHERE clause. "
},{"id":"47",
"q":" Define cascade and inverse option in one-many mapping?",
"answer":"Storing the user’s information within the WEB SERVER memory is called as Server Side State Management. "
},{"id":"48",
"q":" What is a session? How many types of sessions? What is a session? How many types of sessions? ",
"answer":"Session is a temporary variable which will be used to maintain the user information. Based on the locations, sessions are of4 types: 1. Inproc session 2. State server session 3. Sql server session 4. Custom session "
},{"id":"49",
"q":" What is the difference between and merge and update ? ",
"answer":"Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session. "
},{"id":"50",
"q":"What the four ORM levels are in hibernate? ",
"answer":"a. Pure Relational\n\nb. Light Object Mapping\n\nc. Medium Object Mapping\n\nd. Full Object Mapping"
},{"id":"51",
"q":" What the two methods are of hibernate configuration? ",
"answer":"We can use any of the following two methods of hibernate configuration:\n\na. XML based configuration ( using hibernate.cfg.xml file)\n\nb. Programmatic configuration ( Using code logic) "
},
{"id":"52",
"q":"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. "
},{"id":"53",
"q":"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. "
},{"id":"54",
"q":" Which one is the default transaction factory in hibernate?",
"answer":"With hibernate 3.2, default transaction factory is JDBCTransactionFactory."
},{"id":"55",
"q":"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."
},{"id":"56",
"q":"What different fetching strategies are of hibernate?",
"answer":"1. Join Fetching\n\n2. Batch Fetching\n\n3. Select Fetching\n\n4. Sub-select Fetching"
},{"id":"57",
"q":"What are derived properties in hibernate? ",
"answer":"Derived properties are those properties which are not mapped to any columns of a database table. Such properties are calculated at runtime by evaluation of any expressions."
},{"id":"58",
"q":"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."
},{"id":"59",
"q":" Does hibernate support polymorphism? ",
"answer":"Yes, hibernate fully supports polymorphism. Polymorphism queries and polymorphism associations are supported in all mapping strategies of hibernate."
},{"id":"60",
"q":"What the three inheritance models are of hibernate? ",
"answer":"Hibernate has following three inheritance models:\n\na. Tables Per Concrete Class\n\nb. Table per class hierarchy\n\nc. Table per sub-class"
}
]
}