edit uuid values

hi!

I am doing a copy function for all tables.
my primary key is a text with sequence uuid generator
for the copy function that creates a duplicate record in all the tables having the same userid

e.g.
tproduct table

  1. productid = 6E18D017-F54A-4D36-942A-162FEA1070EB, userid = 1543272A-1C31-40CA-8F99-14F94E4E0BB2

tuser table

  1. userid = 1543272A-1C31-40CA-8F99-14F94E4E0BB2

in order to create a non-duplicate record, I replace the first 8 characters with a prefix like (AAAAAAAA, AAAAAAAB, AAAAAAAC, etc)
after execution, the tables will now have
tproduct table
1.productid = 6E18D017-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
2.productid = AAAAAAAA-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
3.productid = AAAAAAAB-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
4.productid = AAAAAAAC-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
5.productid = AAAAAAAD-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
6.productid = AAAAAAAE-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
7.productid = AAAAAAAF-F54A-4D36-942A-162FEA1070EB, userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2

tuser table
1.userid = 1543272A-1C31-40CA-8F99-14F94E4E0BB2
2.userid = AAAAAAAA-1C31-40CA-8F99-14F94E4E0BB2
3.userid = AAAAAAAB-1C31-40CA-8F99-14F94E4E0BB2
4.userid = AAAAAAAC-1C31-40CA-8F99-14F94E4E0BB2
5.userid = AAAAAAAD-1C31-40CA-8F99-14F94E4E0BB2
6.userid = AAAAAAAE-1C31-40CA-8F99-14F94E4E0BB2
7.userid = AAAAAAAF-1C31-40CA-8F99-14F94E4E0BB2

I thought this was ok but at some time it started to give me a wrapped exception for “AAAAAAAG”
record.userid = “AAAAAAAG-1C31-40CA-8F99-14F94E4E0BB2”

"Error during evaluation:Wrapped java.lang.IllegalArgumentException: Setting dataprovider with name 'idsystem_organization', type 'TEXT' with value of wrong type AAAAAAAG-1C31-40CA-8F99-14F94E4E0BB2"

However, I tried this pattern and it worked. After AAAAAAAF, then AAAAAABA to AAAAAABF, so on…

How am I be going to make them unique in the simplest way? Generating a new UUID and updating the foreign keys etc will take a very long time to process.

Hi Rogel,

It’s pretty simple.
A UUID is a Universally Unique IDentifier. You just made it LESS unique by tinkering with them.
If you want unique ID’s you need to generate new UUID’s.

How am I be going to make them unique in the simplest way? Generating a new UUID and updating the foreign keys etc will take a very long time to process.

I feel your pain but it IS the proper way to do this.

Hi guys,

ROCLASI, what we are trying to do is restore a copy of the set of records that are already in the database.
We cannot just generate a new UUID because our customer record may have related child records, so we’re going to have to deal with replacing the foreign keys in the child tables with the new UUID generated for the primary customer record.
To simplify the process we want to just make up a prefix, like AAAA and replace the first several characters in all UUIDs of our records with it.
This way, they will all still be unique and we won’t have to maintain the foreign keys - except for adding the new prefix to them, too.

I hope it makes sense.

So my question is: is it ok to tamper with the UUID and replace part of it with our prefix?

Cheers,
Maria

Try wrapping your “new and improved” UUIDs (I’m with Robert on this one) with:

application.getUUID("AAAAAAAA-3091-478B-BEA4-D5FD4516FCA1")

UUIDs are actually a type of object even if stored as strings in the backend. This function coerces a string into the UUID object type. If the UUID flag is on for a column, Servoy normally expects to be passed a UUID object to put into that column, not a string.