Hibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked
Hibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked
Struts Interview
Questions
Review these typical interview questions and think about how you would
answer them. Read the answers listed; you will find best possible answers
along with strategies and suggestions.
This page is intentionally left blank.
Hibernate
This page is intentionally left blank.
Chapter 1
Hibernate Interfaces
Hibernate Configuration
a) DTD: doctype
b) Configuration of JDBC connection: driver class, url,
username, password
c) Dialect: specify the type of sql to be generated
d) Size of Connection Pool
e) Specify hbm2ddl.auto: automatic generation of database
schema
f) Map hbm.xml files: include Hibernate Mapping files
Answer:
If the column attribute is not given hibernate will map the column
-name as the property name. However if is given as
property name, column should be explicitly given since date is a
keyword.
<property name="date" column="created_date"/>
12: How are the columns of the database mapped with the java
class properties in hibernate?
Answer:
The columns of the database are mapped with the java class
properties in hibernate as follows:
a) Write POJO (getters and setters) class
b) Create hibernate mapping file where
mapping between table columns and the class properties
are specified
<hibernate-mapping>
<class name="empl" table="empl_tabl">
<property name="name" column="empl_name">
<property name="age" column="empl_age"/>
<many-to-one name="dept" cascade="all"
column="dept_Id"/>
</class>
</hibernate-mapping>
13: If you want to insert data for few columns into a large table
with hundreds of columns, hibernate will generate the insert sql
query at run time containing all the table columns which will
create performance issue. How will you make the hibernate to
generate dynamically generated sql queries containing only the
necessary columns? For instance, it should not include the null
columns / property values.
Answer:
We can make the hibernate to generate dynamically generated sql
queries using dynamic- attribute in the class
mapping. Default option is .
<class table="UserDetails" catalog="ks" dynamic-
insert="true" >
...
</class>
<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>