There are two different ways you can generate UUIDs with Talend to use as keys in MySQL. One of which is the all java method, the other uses MySQL itself to generate the UUIDs.
First, the all java method:
As of Java 1.5, Sun has incorporated a UUID class within the standard edition API. This class,
java.util.UUID contains a static method to generate a random UUID. So, for instance, UUID.randomUUID() will generate a new UUID. In a single line of code, you can have a UUID in String form that you can use in the database. For example, UUID.randomUUID().toString() will do this. In Talend there are several ways you can utilize this, which varies depending upon your needs. Below you'll find a couple of examples that show ways to do this.
One way you can utilize a UUID, is to place it in the global map. This can be done with a tSetGlobalVar component. This is shown in the image named setglobalvalue.JPG. From there, it can be retrieved by calling globalMap.get("UUID").toString(). This is shown in the image named gettingfromglobalmap.JPG. In the example job I created, I use a Variable in a tMap to do this, you can also do so in the mapped schema. The benefit of placing it into a variable field is that you can use it in more than one output row without having to write the same globalMap statement more than once, this is evidenced in the image named MappingTheData.JPG. From there, you can use tMySQLOutput components to place them into the database.
In my example job, I have two tables in the database. Both of which have a UUID as the primary key. One of them has a foreign key dependency on the UUID in the other table. The job in its entirety is in the image UUIDWholeJob.JPG.
Next, getting a UUID from the database:
Getting a UUID from MySQL is a simple query "SELECT UUID() UUID." That presents a problem as it will only get one UUID from the database and we need one for each row in the flow. At this point, if we take our row generator and turn its output flow into an iterate, we can grab a UUID from MySQL for each of the rows. This has the caveat of placing the values into the globalMap, which means that for our output from the tMap, we'll need to grab them back out of the globalMap. The schema and query for the tMySQLInput that I use to grab the UUID from the database is shown in image GettingFromMySQL.JPG. Lastly, we have to get the data back out of the globalMap to use in the tMap, how to do this is shown in the mysqltMap.JPG