Skip to main content

Posts

Hibernate Interview Questions

Q)What are the different Transaction Factories available with Hibernate? A) There are three types of Tx Factory available in hibernate JDBCTransactionFactory, JTATransactionFactory and CMTTransactionFactory. Q) Which one is the default transaction factory in Hibernate 3.2? A)JDBCTransactionFactory is the default local transaction factory withHibernate 3.2. Q)Can Hibernate Session Factory be bound to JNDI? A) Yes, by configuring in hibernate.cfg file, session factory can be bound to initial context (as defined by properties hibernate.jndi.url and hibernate.jndi.class). Example: You have to expose this property hibernate.session_factory_name= java:/hibernate/MySessionFactory in hibaernate.cfg file. hibernate.jndi.class = com.sun.jndi.fscontext.RefSContextFactory hibernate.jndi.url = file:/auction/jndi In side HibernateUtil class SessionFactory sf = (SessionFactory) new IntialContext().lookup("/hibernate/MySessionFactory") Q) Can Hibernate be used to call stored procedur...

Spring’s AOP with Struts

Using Spring’s AOP with your Struts Application: To tackle cross-cutting you can use Spring interceptors To use Spring’s AOP in your Struts Applications you need to : 1. Create the interceptor. 2. Registor the interceptor. 3. Delclare interceptors. For example A sample logging interceptor package net.champ.example1.employee.interceptors; import org.springframework.aop.MethodBeforeAdvice; import java.lang.reflect.Method; public class LoggingInterceptor implements MethodBeforeAdvice { public void beforeMethod(Method method, Object[] objects, Object o) throws Throwable { System.out.println("logging before intersection"); } } This interceptor will execute the beforeMethod() before every intersection (We are using MethodBeforeAdvice). Here we are just printing a line but we can use it for anything we like. Next let us register the interceptor. Registering the interceptor in the Spring config file <?xml version="1.0" encoding="UTF-8...

Struts and Springs Integration

Integration using ActionSupport Integrating Struts with Spring doesn’t sound to be easy but if you follow this method you will find it quite simple and to add to this Spring provides you with org.springframework.web.struts.ActionSupport class. This class provides a method getWebApplicationContext() which you can use to obtain the Spring context. So you just have to extend Spring’s ActionSupport from your strut’s actions. Using ActionSupport to integrate Struts package net.champ.example1.actions; import java.io.IOException; import javax.servlet.*; import org.apache.struts.action.*; import org.springframework.context.ApplicationContext; import org.springframework.web.struts.ActionSupport; import net.champ.example1.beans.Employee; import net.champ.example1.business.EmpSearchService; public class SubmitSearch extends ActionSupport { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOExcep...

Spring Interview Questions

Q) What is IOC (or Dependency Injection)? A) The basic concept of the Inversion of Control pattern (also known as dependency injection) is that you do not create your objects but describe how they should be created. You don’t directly connect your components and services together in code but describe which services are needed by which components in a configuration file. A container (in the case of the Spring framework, the IOC container) is then responsible for hooking it all up. i.e., Applying IoC, objects are given their dependencies at creation time by some external entity that coordinates each object in the system. That is, dependencies are injected into objects. So, IoC means an inversion of responsibility with regard to how an object obtains references to collaborating objects. Q) What are the different types of IOC (dependency injection) ? A) There are three types of dependency injection: –> Constructor Injection : Dependencies are provided as constructor parameters. –>...

Flash Lite Application Set Up

Steps to develop an mobile application on flash lite and deploy the same on some device. Step 1: Download Adobe Flash CS4 from net step 2 : Follow the instructions to execute the Adobe flash set up. After every thing installed successfully, follow the below instructions to develop your first Flash Lite Application Hello Mobile World: Creating Your First Flash Lite Project This section contains step-by-step instructions to walk you through the creation of your first Flash Lite Project. This section assumes that you have downloaded and installed Flash CS3 Professional which includes Adobe Device Central. 1.Start Flash CS3 Professional 2.File > New > Flash File (Mobile) 3.Adobe Device Central starts up to allow you to choose the main target device 4.In the 'Device Sets' panel choose 'Flash Lite 2.1 32 240x320'. This is the generic mobile device profile provided by Adobe for a Flash Lite 2.1 device. 5.Click the 'Create' button at the bottom right of Device Ce...

Flex Component Life Cycle

Flex Component Life Cycle Flex component life cycle is useful when you want to create your own component to suit your application requirement. The entire process has been divided into three broad categories. 1. Initialization phase 2. Update Phase 3. Destruction Phase Initialization Phase: The first phase of component life cycle. Again it contains four stages. 1. construction Stage 2. Configuration Stage 3. Attachment Stage 4. Initialization Stage Construction Stage: The constructor of the component is called by the MXML component tag or by using the new operator of Action script class. This is the very first stage where the component life cycle begins. Constructor of the component calls the super () to invoke the super class constructor. Commonly we create out custom component by extending the UIComponent class, as it is base class for all display components of flex framework. The stage is used to: i) set some initial values for component properties ii) add event listener to the...