Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to take the value from tHashInput component ?

Hi,
which options we have when we want to fetch value (one db table record fetched using tMysqlInput) from tHashInput component when Talend Job is started in Java application?
I know that we can store that record in some CSV file for example using tFileOutputDelimited and parse the file later, but is there any other options how can fetch this value in Java application without writing record in the file first?
If it is possible, providing small Java snippet of fetching DB record which is stored in tHashInput would be very helpful.
Thanks,
Nenad
Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi all,
I found the way to store values from tHashInput component to globalMap object and to fetch these values in Java application.
So after tHashInput component I put tJavaRow component. In tJavaRow component I created new HashMap and inside that map I put db table record. After that I put that HashMap instance to globalMap in the same jJavaRow component.
//Instantiate metadata Map

java.util.Map<java.lang.String, java.lang.Object> docMetadata = new java.util.HashMap<java.lang.String, java.lang.Object>();


//Fetch document metadata and put it in the Map

docMetadata.put("documentID", metadata1.DocumentID);

docMetadata.put("documentName", metadata1.DocumentName);

docMetadata.put("creator", metadata1.Creator);


//Put metadata in global Map

globalMap.put("docMetadata", docMetadata);
metadata1 is connection name from tHashInput component to tJava component.
When I started job in Java application I fetched globalMap using Java reflection.

View solution in original post

13 Replies
Anonymous
Not applicable
Author

Hi,
but is there any other options how can fetch this value in Java application without writing record in the file first?

Do you want the Data write model as "Cache in Memory" mentioned in component TalendHelpCenter:/tHashOutput?

Best regards
Sabrina
Anonymous
Not applicable
Author

Hi Sabrina,
thank you for your answer. 
I am already using tHashOutput component to store data in memory and after that tHashInput to read data from memory. This job I started from Java application. But missing part for me is how I can fetch that data from tHashInput component in Java application , is there any method on job object that I can use to fetch that data?
Please note that I am new in Talend and this is my first Talend job. Basically I am reading record from MySQL DB using tMysqlInput , store that result in memory using tHashOutput, fetching that using tHashInput and loging result using tLogRow component. I will attach my job to this post. If you see something that is not logical in design please let me know.
So the question is how I can read tHashInput data in Java application? Please give me example if it is possible.


0683p000009MAyD.png
Thanks,
Nenad
Anonymous
Not applicable
Author

Hi all,
does anybody has solution for this case?
Thanks,
Nenad
janhess
Creator II
Creator II

What problems are you having with your job?
Anonymous
Not applicable
Author

Hi janhess,
I can start job and in the logs I see results, but how I can take these records in Java application?
I want to take db record and place it in some Map to be able to process it later? What is the right way to do it?
Thanks,
Nenad
janhess
Creator II
Creator II

just join the tHashInput to a tMap but it would be easier to link the dbinput to a tMap
Anonymous
Not applicable
Author

After tHashInput connection to tMap, how I can fetch that Map in Java code?
I am starting job like this:
FetchDocuments mySQLConnectorJob = new FetchDocuments(); 
mySQLConnectorJob.runJob(new String[]{});
janhess
Creator II
Creator II

Why not just get the data in the java code?
Anonymous
Not applicable
Author

Client asked Talend to be included in architecture. They want to be able to change some things, so I have to use Talend.
Do you know maybe how I can take values from tMap in Java application? Is there any way to do it?
I just tried to find some getter of tMap in Talend object but without success.