Which of these are true of state changes of an object?
A. State changes from Persistent to Detached on session.close() during a Read operation
B. State changes from Persistent to Detached on session.delete() during a Delete operation
C. State changes from Transient to Persistent on session.delete() during a Delete operation
D. State changes from Transient to Detached on session.close() during a Read operation
2
Which of these is NOT true of Annotations?
A. Annotations tell Hibernate how to persist a class
B. Entity is an annotation that can be imported from javax.persistence
C. Annotation is prefixed by @ symbol
D. Property is an annotation that can be imported from javax.persistence
3
What are NOT valid annotations for embedded objects?
A. @embeddedObjects
B. @embedded
C. @AttributeOverride
D. @AttributeOverrides
4
session.createCriteria() takes in ________________ as an argument for fetching records
A. Class
B. Query
C. String
D. Integer
5
Which of this is true of keys?
A. Surrogate key can contain duplicates while primary key does not
B. Surrogate Key is not business data, but identifies a record uniquely
C. Primary Key and Surrogate Key can be used interchangably
D. Surrogate key is like a column containing serial number of the records
6
Which of these is true of caching in Hibernate?
A. First Level Cache is a level of cache that is provided by default by Hibernate.
B. First Level Cache can be used only witin the session
C. First Level Cache can be implemented across sessions in a single application, while a Second Level Cache can be implemented across applications
D. Second Level of Cache can be implemented across applications and also clusters
7
In order to apply cache to queries, you must set which of these properties in the Hibernate Configuration file?
A. Set both cache.use_second_level_cache to true and cache.use_query_cache to true. These work together
B. Set only cache.use_second_level_cache to true. This will work for Query as well
C. cache.use_second_level_cache to false and cache.use_query_cache to true. Only one of these can be active at a time
D. cache.use_second_level_cache to true if you use session.get() and cache.use_query_cache to true for any queries
8
With @ManyToMany annotation in User class and @ManyToMany(mappedBy="vehicle") in Vehicle class, Hibernate will create which of these tables?
A. User Details
B. Vehicle
C. Vehicle_UserDetails
D. UserDetails_vehicle
9
Which is the right way to use session.get() method?
A. user = (UserDetails) session.get(Userdetails.UsrId)
B. user = session.get(Userdetails.class, UsrId)
C. user = session.get(Userdetails.UsrId)
D. user = (UserDetails) session.get(Userdetails.class, UsrId)
10
user.setUserName("Test User");
session.save(user);
user.setUserName("Dev User");
will result in
A. Two user records, One with User Name as Test User, and another with UserName as Dev User
B. One user record with UserName as Dev User
C. One user record with UserName as Test User, since no save has been performed on the second user
D. Two user records, One with User Name as Test User, and another as blank record in anticipation of a save
11
Which of these is true of Hibernate Applications?
A. Database needs to be designed
B. JDBC Database needs to be configured
C. DAO Method is required to save object using SQL queries
D. Model Objects should be defined
12
A Value Object
A. Does not have meaning on its own without a parent object
B. Contains values for the attributes of a given object
C. Is used to pass an object as an argument to a function or method
D. None of the above
13
Restrictions are like comparisons in a Where Clause os an SQL Query. Which of these are Restrictions for a Criteria?
A. like
B. eq
C. isNull
D. sizeEq
14
Which of these are mandatorily to be executed for saving an object?
A. Obtain SessionFactory from supplied configuration file
B. Initiate Session from sessionFactory.getCurrentSession() and begin the transaction
C. Commit the transaction
D. Close the session
15
To prevent Hibernate from re-creating the database schema on startup, you need to
A. Set the property hbm2ddl.dbupdate to Create
B. Set the property hbm2ddl.dbupdate to Modify
C. Set the property hbm2ddl.auto to Update
D. Set the property hbm2ddl.auto to Modify
16
Projections are used
A. to forecast information based on a data series
B. for aggregating data
C. with Grouping functions
D. for pulling up a specific property of an object
17
In a SingleTable inheritance strategy, Hibernate will create
A. No table for base class since it is an abstract class and one single table for all the sub-classes put together
B. One table for the Base Class and one single table for all sub-classes put together
C. One single table for the base class and all the sub-classes put together
D. One table for Base Class and one table each for each of the sub-classes
18
CollectionId annotation is a feature of
A. JPA and Hibernate
B. Hibernate only
C. JPA only
D. None of the above
19
minUserId = "5 or 1=1" is a SQL injection on the function session.createQuery(" from Userdetails where UserId > " + minUserId), since
A. It is updating a String input field which is used as a parameter in the query
B. it fetches all records instead of only the intended records with UserId > 5
C. the query is built with a paramter
D. None of the above
20
If a UserDetails object had an embedded collection of addresses, then session.get(UserDetails.class,1) would fetch
A. All addresses associated with UserDetails
B. Only the first address in the list of addresses associated with UserDetails
C. Only the UserDetails data without any of the addresses
D. the nth address as per default specified in Hibernate Configuration File