Professional Documents
Culture Documents
Hibernate: 1.should Have API For Performing Select, Insert, Update, Delete Operations On Object of Persistent Classes
Hibernate: 1.should Have API For Performing Select, Insert, Update, Delete Operations On Object of Persistent Classes
Q1.What is one of the basic requirement for an ORM solution ?choose the most
appropriate answer?
1.Should have API for performing Select,Insert,Update,Delete operations on
object of persistent classes.
2.Should have API for performing Create,Read,Update,Delete operations on
object of persistent classes.
3.Should have API for performing Read,Upadte,,Delete,Search operations on
object of persistent classes.
4.Should have API for performing Read,Insert,Update,Search operations on
object of persistent classes.
Q3.In Hibernate which is a single threaded short lived object that is used by
application to specify atomic units of work
1.Transaction
2.Session
3.Session Factory
4.query
Q11.In Hibernate mapping file which element is used for identifier mapping
and generation
1.<column>
2.<property>
3.<id>
4.<identifier>
Q18.in hibernate ,if u need to assign aliases to the classes in ur HQL ,how
do u assign and create query ?
1. 1.String hql=”From employee Alias of Employee”;
Query q=session.createAliasQuery(hql);
2. 1.String hql=”From employee as emp”;
Query q=session.createQuery(hql);
3. 1.String hql=”Alias emp From Employee”;
Query q=session.createQuery(hql);
4..String hql=” Employee Alias From emp ”;
Query q=session.createAliasQuery(hql);
Q19.Suppose u want to accept an input from the user say “employee_id” and
query the details of “employee_id “ how do u write query in HQL
1.String hql=”FROM employee emp where emp.id=:employee_id”;
Query q=session.createQuery(hql);
q.setParameter(“employee_id”,101);
List results=query.list(); //There is nothing called
“Alias” in query language dont choose those answers…
2. String hql=”FROM emp Alias of Employee where emp.id=:employee_id”;
Query q=session.createQuery(hql);
q.setNamedParameter(“employee_id”,101);
List results=query.list();
Q24.In hibernate whenever a parent object is persisted ,if u need the child
object also to get automatically persisted which is the correct statement ?
1.<set name=”xxx” sabe-update=”cascade”>
2.<set name=”xxx” cascade=”save-update”>
3.<set name=”xxx” unsaved-value=”0”>
4.<set name=”xxx” class=”child”/>
Q26.In hibernate which one of the following will be detached and free to use
in any application layer when session is closed ?
1.Transaction
2.Session.
3.SessionFactory
4.Persistence objects
Q27.How can u get a session object ?
1.SessionFactory.getSession();
2.SessionFactory.openSession();
3.SessionFactory.get(); //Doubt
4.(session)SessionFactory.getObject();
Q29.In hibernate ,which file does the database connection related information
are specified ?
1.Dialects file
2.hibernate.hbm.xml file
3.hibernate.cfg.xml
4.application.xml.cfg
Q35. add a restriction to return the records with salary is equal to 2000
A: Criteria cr = session.createCriteria(Employee.class);
cr.add(Restrictions.eq("salary", 2000));
List results = cr.list();
--------------------------------------------------------------
Criteria cr = session.createCriteria(Employee.class);