81.What are the ways to express joins in HQL?HQL provides four ways of expressing (inner and outer) joins:- 82.Define cascade and inverse option in one-many mapping?cascade - enable operations to cascade to child entities. cascade="all|none|save-update|delete|all-delete-orphan" inverse - mark this collection as the "inverse" end of a bidirectional association. inverse="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? 83.What is Hibernate proxy?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. 84.How can Hibernate be configured to access an instance variable directly and not through a setter method ?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. 85.How can a whole class be mapped as immutable?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. 86.What is the use of dynamic-insert and dynamic-update attributes in a class mapping?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. 87.What do you mean by fetching strategy ?A 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. 88.What is automatic dirty checking?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. 89.What is transactional write-behind?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. 90.What are Callback interfaces?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. 91.What are the types of Hibernate instance states ?Three types of instance states: 92.What are the types of inheritance models in Hibernate?There are three types of inheritance models in Hibernate: 93.Is SessionFactory a thread-safe object?Yes, SessionFactory is a thread-safe object, many threads cannot access it simultaneously. 94.What is Session?It maintains a connection between hibernate application and database. It provides methods to store, update, delete or fetch data from the database such as persist(), update(), delete(), load(), get() etc. It is a factory of Query, Criteria and Transaction i.e. it provides factory methods to return these instances. 95.Is Session a thread-safe object?No, Session is not a thread-safe object, many threads can access it simultaneously. In other words, you can share it between threads. 96.What are the states of object in hibernate?There are 3 states of object (instance) in hibernate. 97.What are the inheritance mapping strategies?There are 3 ways of inheritance mapping in hibernate. 98.How to make a immutable class in hibernate?If you mark a class as mutable="false", class will be treated as an immutable class. By default, it is mutable="true". 99.What is automatic dirty checking in hibernate?The automatic dirty checking feature of hibernate, calls update statement automatically on the objects that are modified in a transaction.
Let's understand it by the example given below: 100.How many types of association mapping are possible in hibernate?There can be 4 types of association mapping in hibernate. |