-1
I own a array of integers, a int[]
.
Is it possible to save it directly to the database without having to Serialize? For example:
CREATE TABLE teste(
numeros integer[]
);
And then use SELECT numeros FROM teste
? I researched and did not find much information about this mainly in Java, most are all in PHP.
Is it recommended to do this? Or is it better to serialize?
You can use the JSON type and save in this format, save as a string in the format you want, for example, CSV, or create a table numbers and add a row for each number referenced to the original table
– Costamilam
I think saving me JSON would be valid too, although I was not in the mood to use JSON I think this is also valid, I think I will follow the tip of Maniero and I will serialize even.
– Eduardo Mior
What a way you went?
– Maniero
I chose to save in
Text
in the database, I usedStringJoiner
to format in java and then turned intoString
to save in the database. At the time of getting the data back from the database I use the functionsplit
, everything works perfectly without errors and this well optimized.– Eduardo Mior