The largest Interview Solution Library on the web


Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

21.Which method is used to re-read the state of the given instance from the underlying database?

Session.refresh re-reads the state of the given instance from the underlying database.

22.Which method is used to save the state of the given instance from the underlying database?

Session.save saves the state of the given instance from the underlying database.

23.Which method is used to update the state of the given instance from the underlying database?

Session.update updates the state of the given instance from the underlying database.

24.Which method is used to save or update the state of the given instance from the underlying database?

Session.saveOrUpdate either savesObject or updatesObject the given instance.

25.What are persistent classes in hibernate?

Java classes whose objects or instances will be stored in database tables are called persistent classes in Hibernate.
What are the best practices that hibernate recommends for persistent classes.
There are following main rules of persistent classes, however, none of these rules are hard requirements.
All Java classes that will be persisted need a default constructor.
All classes should contain an ID in order to allow easy identification of your objects within Hibernate and the database. This property maps to the primary key column of a database table.
All attributes that will be persisted should be declared private and have getXXX and setXXX methods defined in the JavaBean style.
A central feature of Hibernate, proxies, depends upon the persistent class being either nonfinal, or the implementation of an interface that declares all public methods.
All classes that do not extend or implement some specialized classes and interfaces required by the EJB framework.

26.Where Object/relational mappings are defined in hibernate?

An Object/relational mappings are usually defined in an XML document. This mapping file instructs Hibernate how to map the defined class or classes to the database tables. We should save the mapping document in a file with the format .hbm.xml.

27.What is root node of hbm.xml?

The mapping document is an XML document having as the root element which contains all the elements.

28.Which element of hbm.xml defines a specific mappings from a Java classes to the database tables?

The elements are used to define specific mappings from a Java classes to the database tables. The Java class name is specified using the name attribute of the class element and the database table name is specified using the <>btable attribute.

29.Which element of hbm.xml defines maps the unique ID attribute in class to the primary key of the database table?

The element maps the unique ID attribute in class to the primary key of the database table. The name attribute of the id element refers to the property in the class and the column attribute refers to the column in the database table. The type attribute holds the hibernate mapping type, this mapping types will convert from Java to SQL data type.

30.Which element of hbm.xml is used to automatically generate the primary key values?

The element within the id element is used to automatically generate the primary key values. Set the class attribute of the generator element is set to native to let hibernate pick up either identity, sequence or hilo algorithm to create primary key depending upon the capabilities of the underlying database.

31.Which element of hbm.xml is used to map a Java class property to a column in the database table?

The element is used to map a Java class property to a column in the database table. The name attribute of the element refers to the property in the class and the column attribute refers to the column in the database table. The type attribute holds the hibernate mapping type, this mapping types will convert from Java to SQL data type.

32.Which element of hbm.xml is used to map a java.util.Set property in hibernate?

This is mapped with a element and initialized with java.util.HashSet.

33.Which element of hbm.xml is used to map a java.util.SortedSet property in hibernate?

This is mapped with a element and initialized with java.util.TreeSet. The sort attribute can be set to either a comparator or natural ordering.

34.Which element of hbm.xml is used to map a java.util.List property in hibernate?

This is mapped with a element and initialized with java.util.ArrayList.

35.Which element of hbm.xml is used to map a java.util.Collection property in hibernate?

This is mapped with a or element and initialized with java.util.ArrayList.

36.Which element of hbm.xml is used to map a java.util.Map property in hibernate?

This is mapped with a element and initialized with java.util.HashMap.

37.Which element of hbm.xml is used to map a java.util.SortedMap property in hibernate?

This is mapped with a element and initialized with java.util.TreeMap. The sort attribute can be set to either a comparator or natural ordering.

38.What is many-to-one association?

A many-to-one association is the most common kind of association where an Object can be associated with multiple objects. For example a same address object can be associated with multiple employee objects. element is used to define many-to-one association. The name attribute is set to the defined variable in the parent class. The column attribute is used to set the column name in the parent table.

39.What is one-to-one association?

A one-to-one association is similar to many-to-one association with a difference that the column will be set as unique. For example an address object can be associated with a single employee object. element is used to define one-to-one association. The name attribute is set to the defined variable in the parent class. The column attribute is used to set the column name in the parent table which is set to unique so that only one object can be associated with an other object.

40.What is one-to-many association?

In One-to-Many mapping association, an object can be can be associated with multiple objects. For example Employee object relates to many Certificate objects. A One-to-Many mapping can be implemented using a Set java collection that does not contain any duplicate element. element of set element indicates that one object relates to many other objects.

« Previous | 0 | 1 | 2 | 3 | 4 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com