Hibernate Quiz
Hibernate Quiz - 1                    

« 1 2 3 »


1. To obtain a SessionFactory with custom config file, we can use the following :
a) new Configuration().configure("myfile.cfg.xml").buildSessionFactory()
b) new Configuration().configure().buildSessionFactory().
c) new Configuration("mycfg.cfg.xml").buildSessionFactory().
d) new Configuration("mycfg.cfg").buildSessionFactory().

2. Is a SessionFactory thread safe?
a) No.
b) Yes
c) Not applicable.
d) Depends on Environment.
Wrong! Try again.
Wrong!
The correct answer is b) Yes.
SessionFactory is thread safe. Session is not, we need to create a new session for each thread.
Correct!
SessionFactory is thread safe. Session is not, we need to create a new session for each thread..

3. The delete() method in Session does the following :
a) Removes instance from memory.
b) Removes table from db.
c) None of above.
d) Removes a persistent instance from db.
Wrong! Try again..
Wrong!
The correct answer is d) Removes a persistent instance from db. .
Correct!
Removes a persistent instance from db.

4. Which of following is NOT a property in hibernate.cfg.xml file?:
a) connection.url
b) connection.pool_size
c) oracle_dialect
d) None of above
Wrong! Try again..
Wrong!
The correct answer is c) oracle_dialect is not a property ('dialect' is a property)
Correct!
oracle_dialect is not a property. ('dialect' is a property)

5. A mapping file in hibernate for class ‘Trainee’ is generally named as :
a) Trainee.cfg.xml
b) Trainee.hbm.xml
c) Trainee.xml
d) Trainee.hbm

Wrong! Try again..
Wrong!
The correct answer is b) Trainee.hbm.xml
Correct!
Trainee.hbm.xml

6. The <generator> tag is used for :
a) Generating primary key values.
b) Generating table automatically
c) Mapping property to column in table
d) Generating column automatically

Next-->