Saturday, December 29, 2018

SQL Ranking:
select *
  from
  (
    select
        sal
          ,dense_rank() over (order by sal desc) ranking
    from   table
  )
  where ranking = 4 -- Replace 4 with any value of N

Thursday, December 27, 2018

Java 8 : Arrays.stream
Arrays.stream(arr) .sum();
Arrays.stream(arr) .forEach(e->System.out.print(e + " "));
--------------------------------------------------------------


Map < String, List < String >> phoneNumbers = 
new HashMap < String, List < String >> ();
phoneNumbers.put("John Lawson", Arrays.asList("3232312323", "8933555472"));
phoneNumbers.put("Mary Jane", Arrays.asList("12323344", "492648333"));
phoneNumbers.put("Mary Lou", Arrays.asList("77323344", "938448333"));
Map < String, List < String >> filteredNumbers = phoneNumbers
.entrySet()
.stream()
    .filter(x - > x.getKey().contains("Mary"))
    .collect(Collectors.toMap(p - > p.getKey(), p - > p.getValue()));
filteredNumbers.forEach((key, value) - > {
    System.out.println("Name: " + key + ": ");
    value.forEach(System.out::println);

});

Tuesday, December 18, 2018

Spring auto wiring:
1) The default mode in traditional XML based configuration is no.
2) The default mode in java based @Autowired is byType.

Monday, December 17, 2018

Spring: Context Loader Listener:-
--------------------------------------------------------------------------------------------------------------------------ContextLoaderListener creates a root web-application-context for the web-application and puts it in the ServletContext. This context can be used to load and unload the spring-managed beans ir-respective of what technology is being used in the controller layer(Struts or Spring MVC).
Pattern Matcher Example:
You can use the following code:
String in = "i have a male cat. the color of male cat is Black";
int i = 0;
Pattern p = Pattern.compile("male cat");
Matcher m = p.matcher( in );
while (m.find()) {
    i++;
}
System.out.println(i); // Prints 2

Friday, December 14, 2018

Wand Specific: How to get translation labels in JS:
--------------------------------------------------------------------
var violationReason =  Dollar  translate.instant("LBL_RATE_CARD_VIOLATION")+' - '+ Dollar translate.instant("LBL_REASON")

Tuesday, December 11, 2018

How to autowire a Bean:
For @Autowired annotation to work, we also need to enable annotation based configuration in spring bean configuration file. This can be done by context:annotation-config element or by defining a bean of type org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
Properties Files Priority in Spring Boot:
-------------------------------------------------

Wednesday, December 5, 2018

JSTL Taking a value from Map
c:out value="${ObjectGenInfo.customLabelMap['LBL_REQUISITION_DEPT']}"
Map customLabelMap=new HashMap();
    int clientId = cmd.getRequisition().getClientId();
customLabelMap.put("LBL_REQUISITION_DEPARTMENT",Util.getLabel(clientId, "LBL_REQUISITION_DEPARTMENT",locale));
customLabelMap.put("LBL_REQUISITION_DEPT",Util.getLabel(clientId, "LBL_REQUISITION_DEPT",locale));
cmd.setCustomLabelMap(customLabelMap);