Hibernate – Different between session.get() and session.load()

April 13, 2017 Leave a comment

1. session.load()

  • It will always return a “proxy” (Hibernate term) without hitting the database. In Hibernate, proxy is an object with the given identifier value, its properties are not initialized yet, it just look like a temporary fake object.
  • If no row found , it will throws an ObjectNotFoundException.

2. session.get()

  • It always hit the database and return the real object, an object that represent the database row, not proxy.
  • If no row found , it return null.
Categories: Hibernate, JAVA

Running Python code on JVM using Jython

October 28, 2014 Leave a comment

Follow Below Steps :

1) Download Jython2.1.jar 

2) Download jsr223-api.jar

3) Add above jar files in the Class path .

4) Java code sample to excute the python on JVM:

public static void testPython() {

ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor(“python”);

//Example -1:

Object obj= executor.executeScript(new StaticScriptSource(“def foo(y):\n\tx=y\n\treturn y\nz=foo(2)”));

System.out.println(“Excuted successfully ::::”+obj.toString());

//Example -2 :

Object obj2 = executor.executeScript(new ResourceScriptSource(new FileSystemResource(“D:/xyz.py”)));
System.out.println(“Output ::::::::”+ obj2);

}

Categories: J2EE Tags: ,

Twilio Vs Nexmo -SMS service

April 20, 2014 Leave a comment

 

Twilio offers more than just SMS, with their Voice IVR API being the unique API. Nexmo doesn’t offer any voice API, and the inbound numbers they offered is strictly for SMS only. So if you want the same number that can receive SMS and also receive phone calls, Twilio is the only one that can do that.

Categories: Android

SAP Hana – Feeding data from xodata to Pie/Bar Chart

February 13, 2014 2 comments

SAP Hana ,  Getting the data from xodata and feeding it to pie / bar chart for Analytical views 

In your view.js file , define the pie/ bar chart object as below

sap.ui.jsview(“view.ViewName”, {

getControllerName : function() {
return “view.ViewName”;
},

createContent : function(oController) {

var oPage = new sap.m.Page(“homePage”, {
showNavButton : false,
showFooter : false
});

var dataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [
{
axis : 1, // must be one for the x-axis, 2 for y-axis
name : ‘COLOUMN’, //Any name .. preferrably db column name
value : “{COLOUMN}” //database column that you get in while access .xodata
}],

measures : [ {
group : 1,
name : “XYZ_COUNT”,
value : “{XYZ_COUNT}” // this is database count for the columb you chose

}],

data : {
path : “/XXXXXXX”, // this is your context that you define in your .xodata file

}
});

var pie = new sap.viz.ui5.Pie({
width : “100%”,
height : “300px”,
showLegend : false,
plotArea : {
‘colorPalette’ : d3.scale.category20().range()
},
title : {
visible :true,
text : ‘Graph Name’
},
dataset : dataset
});

oPage.addContent(pie);
return oPage;
}
});

Categories: Big Data, SAP Hana

SAP Hana – Different Charts

February 13, 2014 Leave a comment
Categories: Big Data, SAP Hana

search on sorted array which has been rotated to unknown pivot

October 4, 2013 Leave a comment

Binary search with change :

int start = array[0];
int end = array[length -1];
int mid = array[length/2];
int left = 0;
int right = length – 1;

while (left <= right) {
int middle = left + (right-left)/2;
if (array[middle] == find) return middle;

if (array[left] <= array[middle]) {
if (find >= array[left] && find < array[middle])
right = middle – 1;
else
left = middle + 1;
}
else {
if (find > array[middle] && find <= array[right])
left = middle + 1;
else
right = middle – 1;
}
}
return -1;

Categories: JAVA

Quick sort & Merge sort

October 4, 2013 Leave a comment

Quick sort is nothing but a series of recursive calls to partitioning and the fastest comparison sort on arrays in practice.
Merge sort is stable comparison sort, which also works on linked lists .

Categories: JAVA
%d bloggers like this: