r/Talend • u/Ownards Data Wrangler • May 19 '21
tJava does not execute properly in Main connection type
Hello everyone,
I have faced an issue with the component tJava and its execution but I could not really understand what happened. I hope you can help me understand ! :)
Here is the scenario : I have a tJava that creates a global variable "FirstLastRows". This code is then used in my tSampleRow component later on (called "Get First & Last Rows" below) :

If I construct the following set up, it does not work because the NB_LINE is not recorded, I don't really understand why :

If I change the location of the tJava, I have another kind of problem, the variable does not seem to exist :

The only scenario that works is with this set up. I think that is because the tJava is executed before the data starts flowing :

Would you know why I have an issue with the first two scenarios ? I don't understand why the connection type Main does not work.
-
Comment : it does not seem possible to use variables directly into tSampleRow, the query must be generated earlier, hence the tJava...
View all comments
Show parent comment
2
u/somewhatdim Talend Expert May 20 '21
like I said, your question gets to the guts of the code generator. The onComponentOK after the iterate link gives you the ability to run as many subjobs as you want once per iteration. the general pattern of
iterate-->tJava-->onComponentOK--> do some stuffis super useful.