My Quotes


When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY






Tuesday, December 8, 2015

Maven Project Version in application




Getting Project Version to be displayed in the pages without much hassles..


pom.xml file changes 
   
    maven-war-plugin
    2.4
         
     WebContent
     false
    
   

${project.version} in your html file

Repeated columns in JPA


I wanted to define repeated columns in JPA. But when I do, I got the message the second column should be defined as insert="false" , update="false"


 Approach 1: Here is an easy way to do it. In the entity bean define the second property as follows 

        @Column(name="UPLOAD_DATE")
        private Date uploadDate;
        @AttributeOverride(name="uploadDateAsTime", column = @Column
                        (name = "UPLOAD_DATE"))
        private Timestamp uploadDateAsTime;
        @Column(name="UPLOAD_STATUS")
 

 Approach 2: Here is the alternatie way to do it via XML file.. 


it would take care of giving unique names for enbeddable field columns in target entity class.

                
                
                 ddl, callback 
                

Friday, December 4, 2015

Spring Custom Context Loader


Use Spring Custom Context Loader.


import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

import com.fra.exception.ApplicationException;
import com.fra.exception.SystemException;
import com.fra.fv.service.IModuleConfigService;

@WebListener
public class CustomContextListener implements ServletContextListener {
 @Autowired
 @Qualifier(value = "mdlConfigService")
 IModuleConfigService mdlConfigService;
 final static Logger logger = Logger.getLogger(CustomContextListener.class);

 public CustomContextListener() {
  super();
 }

 @Override
 public void contextInitialized(ServletContextEvent event) {
  SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
  try {
   mdlConfigService.loadModuleConfigs();
  } catch (ApplicationException e) {
   logger.error(ExceptionUtil.getFullExceptionAsString(e, 50));
  } catch (SystemException e) {
   logger.error(ExceptionUtil.getFullExceptionAsString(e, 50));
  }
 }

 @Override
 public void contextDestroyed(ServletContextEvent event) {
 }
}