Five Stars

How to use hash in talend

I am inserting data in a table from another.
I would like to add a column hash which has hash of all the columns of each row being inserted. 
How would I do that in Talend? 
One Star

Re: How to use hash in talend

Can you please explain better what do you want to produce?
One Star

Re: How to use hash in talend

1st, define a routine for conversion (here, mine is called GetHashCode and convert to MD5):
package routines;
public class GetHashCode {
public static String getMD5(String strCode) { msg;
String digest1 = "";
try {
msg ="MD5");
msg.update(strCode.getBytes(), 0, strCode.length());
digest1 = new java.math.BigInteger(1, msg.digest()).toString(32);
catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
return digest1.toUpperCase();

In tMap, add the desired field to your schema, then call the routine passing the input fields concateneted, and push the result to the new field (here is an example):
GetHashCode.getMD5(row1.col1 + row1.col2 + row1.col3)

Hope this helps,