In legacy database tables we have numbered columns like C1, C2, C3, C100 or M1, M2, M3, M100.
This columns represent BLOB data.
It is not possible to change anything it this database.
By using JPA Embeddable we map all of the columns to single fields. And then during embedding we override names by using 100 override annotations.
Recently we have switched to Hibernate and I've found things like UserCollectionType and CompositeUserType. But I hadn't found any use cases that are close to mine.
Is it possible to implement some user type by using Hibernate to be able to map a bundle of columns to a collection without additional querying?
Edit:
As you probably noticed the names of columns can differ from table to table. I want to create one type like "LegacyArray" with no need to specify all of the @Columns each time I use this type.
But instead I'd use
@Type(type = "LegacyArrayUserType",
parameters =
{
@Parameter(name = "prefix", value = "A"),
@Parameter(name = "size", value = "128")
})
List<Integer> legacyA;
@Type(type = "LegacyArrayUserType",
parameters =
{
@Parameter(name = "prefix", value = "B"),
@Parameter(name = "size", value = "64")
})
List<Integer> legacyB;