Thursday 15 October 2015

Spring , Struts and hibernate Question



Spring ::


1)- How Spring Transaction Works
2)- Spring MVC architecture.
3)- Internal implementation of bean factory
4)- how DI work and why it comes in picture
5)- What is global session
6)- Autowiring by name, type?
7)- Spring bean scopes?
8)- which design pattern is spring based on ?
9)- Can a JSP be used as controllor in MVC architecture ? If NO, why ?
10)-How does Spring AOP works?
11)- Autowiring types and their differences
12)- how many instance will be created if we declare two different bean id pointing to same class
13)- If a bean is singleton in spring does it produce a new instance if I use that with new operator in plain java file
14)- how will u ensure that there is no any circular dependency
15)-Which proxy used by Spring

Struts ::

1. Explain struts architecture
2. how to implement own interceptor
3. How param interceptor works in struts?
4. How to get form values from client in our action class in struts?
5. What is TokenInterceptor in struts and how it works internally, where it keeps tokens?
6. How you can migrate struts1.2 to struts 2.
7.  How interceptor and actioninvocation works with each other
8.  how do u handle transaction ?difference between require new and nested

Hibernate ::

1. how connection pool works , if you have created pool with size 10 and in your system 15 user comes concurrent. So how it handle.

2. Different Type of Interface in Hibernate.

3.What is transaction.

4. session.save() VS session.persistent();
5.  session.update() VS session.merge().
6. How to create alias in hibernate?
7. How cache works in hibernate(first and second level).
8.
<bean id="student" class="com.example.model.Student" scope="singalton">
        <property name="address">
            <bean class="com.example.model.Address" scope="prototype">
                <property name="address" value="Noida K-Block" />
            </bean>
        </property>
        </bean>
       b. <bean id="student" class="com.example.model.Student" scope="prototype">
        <property name="address">
            <bean class="com.example.model.Address" scope="singalton">
                <property name="address" value="Noida K-Block" />
            </bean>
        </property>
        </bean>

what is difference between a and b?

9. lazy loading and inverse true work in hibernate.

10. What is two phase commit.
11. what are the elements in hibernate xml.
12. explain hib inheritence till db layer
13.Write criteria query to fetch only 3 columns from table like if we have table with column name     
       transId, transName, StuId, StuName, EnrollId, EnollName.
From above 6 column I need to fetch only transId, StuId and EnrollId using criteria.


Projection API is used to fetch any number of columns from table.

Criteria criteria = session.createCriteria(UserInfo.class);
    ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("firstName"), "firstName");
    proList.add(Projections.property("lastName"), "lastName");
    criteria.setProjection(proList);
    criteria.list(),

will return list of objects with only two columns.
we can transfer this result to our Custom object using transformation like:
List<UserDTO> list = criteria.setResultTransformer(Transformers.aliasToBean(UserDTO.class))
      .list();
UserTDO is custom object with firstName and lastName properties and their getter setter.


ProjectionList is necessary when we want to get multiple column. We can add Projections directly to criteria but if we add two Projections without  ProjectionList it will override previously added Projection and only one last added projection will be applied.
NOTE: one more important thing if we want to transform result to our Custom object the second parameter on ProjectionList’s add method should be same as the property name in custom object, otherwise it is not required.

No comments:

Post a Comment