HIBERNATE INTERVIEW QUESTION
Q1. Which statement is correct ?
1 session.contains() method to determine if an instance belongs to the session cache.
2 session.contains() method to determine if an instance belongs to the data base .
3 Both are correct
4 none of the above
You have choosen : 4Correct Answer is : 1You were wrong.
Q2. What does hibernate.show_sql true mean ?
1 show sql results on console.
2 show sql inputs on console.
3 show sql statement on console.
4 None
You have choosen : 3Correct Answer is : 3You were correct.
Explanations : null
Q3. What is the naming convention for Hibernate XML mapping file extensions?
1 .hbm.xml
2 .hhm.xml
3 .hb.xml
4 none of the above
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q4. What does session.createCriteria().uniqueResult() return ?
1 Object
2 String
3 ResultSet
4 HibernateResultSet
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q5. ____ forces hibernate to bypass the setter method and access the instance variable directly while initializing a newly loaded object.
1 By mapping the property with access="onlyfield" in Hibernate metadata
2 By mapping the property with access="variable" in Hibernate metadata
3 By mapping the property with access="field" in Hibernate metadata
4 none of the above
You have choosen : 1Correct Answer is : 3You were wrong.
Explanations : null
Q6. What does session.load() return if there is no matching database row ?
1 NULL
2 Empty Object
3 unrecoverable exception
4 None of the above
You have choosen : 1Correct Answer is : 3You were wrong.
Explanations : null
Q7. It is possible to re-load an object and all its collections at any time, using the xxxx() method. This is useful when database triggers are used to initialize some of the properties of the object. What is the xxxx() method ?
1 refresh();
2 flush();
3 fetch();
4 load()
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q8. What happens when both hibernate.properties and hibernate.cfg.xml are in the classpath?
1 The settings of the properties file will override the settings used in the XML configuration
2 The settings of the XML configuration file will override the settings used in the properties
3 DuplicateConfigurationException
4 None
You have choosen : 3Correct Answer is : 2You were wrong.
Explanations : null
Q9. What is the naming convention for Hibernate XML mapping file extensions?
1 .hibernate.xml
2 .hbm.xml
3 .hibernate_data.xml
4 none
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q10. What is dirty checking in Hibernate?
1 bject state changes in order to synchronize the updated state with the database
2 remove the dirty data from data base.
3 check the data when insert into data base.
4 None
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q11. If instances are not in the session or second-level cache which will give better performance?
1 Query.list()
2 Query.iterate()
3 Both are same
4 None of the above
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q12. Which fetching strategy tuned query automatically ?
1 session.createQuery();
2 session.createCriteria();
3 session.createSQLQuery();
4 None Of the above
You have choosen : 3Correct Answer is : 2You were wrong.
Explanations : null
Q13. Is Hibernate Session threadsafe?
1 threadsafe
2 not threadsafe
3 No relation to Thread
4 None of the above
You have choosen : 2Correct Answer is : 2You were correct.
Explanations : null
Q14. In the .bhm.xml file ? ] ]> What is correct way of executipon of the above query in the .bhm.xml file.
1 Query q = sess.getNamedQuery("abc");
2 Query q = sess.createQuery("abc");
3 Query q = sess.createSQLQuery("abc");
4 none of the above
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q15. What is Configuration interface in hibernate?
1 used to create SessionFactory.
2 used to create Session.
3 used to create Transaction.
4 none of the above
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q16. By default, Hibernate uses _ for JVM-level caching.
1 OSCache
2 EHCache
3 JBOSSCache
4 None of the above
You have choosen : 1Correct Answer is : 2You were wrong.
Q17. Which Cache Strategy particularly useful in cases where underlying data may have been updated via a separate process (i.e., not modified through Hibernate)?
1 Query.setCacheMode(CacheMode.READ).
2 Query.setCacheMode(CacheMode.REFRESH).
3 Query.setCacheMode(CacheMode.NONE).
4 Query.setCacheMode(CacheMode.REFRESHDATABASE).
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Q18. What does session.evict() method do ?
1 remove the object and its collections from the first level cache
2 remove the object and its collections from the second level cache
3 remove the object and its collections from the data base
4 None of the above
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q19. Is the below code work ? Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); } tx.commit(); session.close();
1 true
2 false
3 can't say
4 none
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Q20. SessionFactory represent which level of cache ?
1 2nd
2 Ist
3 3rd
4 4th
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q21. How can get a session object ?
1 SessionFactory.getSession();
2 SessionFactory.openSession();
3 SessionFactory.get();
4 (session)SessionFactory.getObject();
You have choosen : 1Correct Answer is : 2You were wrong.
Q22. To completely evict all objects from the session cache which method is appropriate ?
1 Session.evict()
2 Session.clear()
3 Session.flush()
4 None of the above
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Hibernate Mock Online test
Q23. What Session.flush() do ?
1 the state of that object will be synchronized with the database.
2 the state of that object will be synchronized with the SessionFactory.
3 remove state of that object from Session.
4 remove state of that object from SessionFactory.
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q24. How to create SessionFactory ?
1 configuration.buildSessionFactory();
2 configuration.createSessionFactory();
3 configuration.createNewSessionFactory();
4 none of the above
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q25. Difference between Emp e = session.load(Emp.class) and Emp e = session.createCriteria(Emp.class) ?
1 On session close session.load() Emp Object unavilabe to access.
2 On session close session.createCriteria() Emp unavilabe to access.
3 None
4 None
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q26. Which statement is correct ?
1 A Session will not obtain a JDBC Connection (or a Datasource) unless it is needed
2 A Session will obtain a JDBC Connection (or a Datasource) on object create
3 A Session has no relation with JDBC Connection (or a Datasource)
4 none of the above
You have choosen : 1Correct Answer is : 1You were correct.
Q27. what is the default value in hibernate ?
1 lazy=false;
2 lazy=true;
3 lazy=yes;
4 lazy=no;
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Q28. Which statement is correct
1 The CacheMode controls how a particular session interacts with the second-level cache.
2 The CacheMode don't controls session interaction with the second-level cache.
3 both
4 none
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q29. Which statement is true about session.saveOrUpdate()?
1 if another object associated with the session has the same identifier, throw an exception
2 if the object has no identifier property, save() it
3 Both of the above
4 none of the above
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q30. Which statement is correct ?
1 Specifying join as the fetch strategy in the mapping document does affect HQL queries.
2 Specifying join as the fetch strategy in the mapping document does not affect HQL queries.
3 None
4 None
You have choosen : 1Correct Answer is : 2You were wrong.
Q1. Which statement is correct ?
1 session.contains() method to determine if an instance belongs to the session cache.
2 session.contains() method to determine if an instance belongs to the data base .
3 Both are correct
4 none of the above
You have choosen : 4Correct Answer is : 1You were wrong.
Q2. What does hibernate.show_sql true mean ?
1 show sql results on console.
2 show sql inputs on console.
3 show sql statement on console.
4 None
You have choosen : 3Correct Answer is : 3You were correct.
Explanations : null
Q3. What is the naming convention for Hibernate XML mapping file extensions?
1 .hbm.xml
2 .hhm.xml
3 .hb.xml
4 none of the above
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q4. What does session.createCriteria().uniqueResult() return ?
1 Object
2 String
3 ResultSet
4 HibernateResultSet
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q5. ____ forces hibernate to bypass the setter method and access the instance variable directly while initializing a newly loaded object.
1 By mapping the property with access="onlyfield" in Hibernate metadata
2 By mapping the property with access="variable" in Hibernate metadata
3 By mapping the property with access="field" in Hibernate metadata
4 none of the above
You have choosen : 1Correct Answer is : 3You were wrong.
Explanations : null
Q6. What does session.load() return if there is no matching database row ?
1 NULL
2 Empty Object
3 unrecoverable exception
4 None of the above
You have choosen : 1Correct Answer is : 3You were wrong.
Explanations : null
Q7. It is possible to re-load an object and all its collections at any time, using the xxxx() method. This is useful when database triggers are used to initialize some of the properties of the object. What is the xxxx() method ?
1 refresh();
2 flush();
3 fetch();
4 load()
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q8. What happens when both hibernate.properties and hibernate.cfg.xml are in the classpath?
1 The settings of the properties file will override the settings used in the XML configuration
2 The settings of the XML configuration file will override the settings used in the properties
3 DuplicateConfigurationException
4 None
You have choosen : 3Correct Answer is : 2You were wrong.
Explanations : null
Q9. What is the naming convention for Hibernate XML mapping file extensions?
1 .hibernate.xml
2 .hbm.xml
3 .hibernate_data.xml
4 none
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q10. What is dirty checking in Hibernate?
1 bject state changes in order to synchronize the updated state with the database
2 remove the dirty data from data base.
3 check the data when insert into data base.
4 None
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q11. If instances are not in the session or second-level cache which will give better performance?
1 Query.list()
2 Query.iterate()
3 Both are same
4 None of the above
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q12. Which fetching strategy tuned query automatically ?
1 session.createQuery();
2 session.createCriteria();
3 session.createSQLQuery();
4 None Of the above
You have choosen : 3Correct Answer is : 2You were wrong.
Explanations : null
Q13. Is Hibernate Session threadsafe?
1 threadsafe
2 not threadsafe
3 No relation to Thread
4 None of the above
You have choosen : 2Correct Answer is : 2You were correct.
Explanations : null
Q14. In the .bhm.xml file
1 Query q = sess.getNamedQuery("abc");
2 Query q = sess.createQuery("abc");
3 Query q = sess.createSQLQuery("abc");
4 none of the above
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q15. What is Configuration interface in hibernate?
1 used to create SessionFactory.
2 used to create Session.
3 used to create Transaction.
4 none of the above
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q16. By default, Hibernate uses _ for JVM-level caching.
1 OSCache
2 EHCache
3 JBOSSCache
4 None of the above
You have choosen : 1Correct Answer is : 2You were wrong.
Q17. Which Cache Strategy particularly useful in cases where underlying data may have been updated via a separate process (i.e., not modified through Hibernate)?
1 Query.setCacheMode(CacheMode.READ).
2 Query.setCacheMode(CacheMode.REFRESH).
3 Query.setCacheMode(CacheMode.NONE).
4 Query.setCacheMode(CacheMode.REFRESHDATABASE).
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Q18. What does session.evict() method do ?
1 remove the object and its collections from the first level cache
2 remove the object and its collections from the second level cache
3 remove the object and its collections from the data base
4 None of the above
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q19. Is the below code work ? Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); } tx.commit(); session.close();
1 true
2 false
3 can't say
4 none
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Q20. SessionFactory represent which level of cache ?
1 2nd
2 Ist
3 3rd
4 4th
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q21. How can get a session object ?
1 SessionFactory.getSession();
2 SessionFactory.openSession();
3 SessionFactory.get();
4 (session)SessionFactory.getObject();
You have choosen : 1Correct Answer is : 2You were wrong.
Q22. To completely evict all objects from the session cache which method is appropriate ?
1 Session.evict()
2 Session.clear()
3 Session.flush()
4 None of the above
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Hibernate Mock Online test
Q23. What Session.flush() do ?
1 the state of that object will be synchronized with the database.
2 the state of that object will be synchronized with the SessionFactory.
3 remove state of that object from Session.
4 remove state of that object from SessionFactory.
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q24. How to create SessionFactory ?
1 configuration.buildSessionFactory();
2 configuration.createSessionFactory();
3 configuration.createNewSessionFactory();
4 none of the above
You have choosen : 3Correct Answer is : 1You were wrong.
Explanations : null
Q25. Difference between Emp e = session.load(Emp.class) and Emp e = session.createCriteria(Emp.class) ?
1 On session close session.load() Emp Object unavilabe to access.
2 On session close session.createCriteria() Emp unavilabe to access.
3 None
4 None
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q26. Which statement is correct ?
1 A Session will not obtain a JDBC Connection (or a Datasource) unless it is needed
2 A Session will obtain a JDBC Connection (or a Datasource) on object create
3 A Session has no relation with JDBC Connection (or a Datasource)
4 none of the above
You have choosen : 1Correct Answer is : 1You were correct.
Q27. what is the default value in hibernate ?
1 lazy=false;
2 lazy=true;
3 lazy=yes;
4 lazy=no;
You have choosen : 1Correct Answer is : 2You were wrong.
Explanations : null
Q28. Which statement is correct
1 The CacheMode controls how a particular session interacts with the second-level cache.
2 The CacheMode don't controls session interaction with the second-level cache.
3 both
4 none
You have choosen : 1Correct Answer is : 1You were correct.
Explanations : null
Q29. Which statement is true about session.saveOrUpdate()?
1 if another object associated with the session has the same identifier, throw an exception
2 if the object has no identifier property, save() it
3 Both of the above
4 none of the above
You have choosen : 2Correct Answer is : 1You were wrong.
Explanations : null
Q30. Which statement is correct ?
1 Specifying join as the fetch strategy in the mapping document does affect HQL queries.
2 Specifying join as the fetch strategy in the mapping document does not affect HQL queries.
3 None
4 None
You have choosen : 1Correct Answer is : 2You were wrong.
No comments:
Post a Comment