Hi all,

I’m new to Cayenne and coming from the WebObjects world I’m trying to figure 
out how to adjust to the different environment. I was looking for some simple 
advice on how to do conversions for custom types.

In particular, how would I go to save a collection based object. Let’s say I 
have a List<LocalDateTime> and my database is holding data as a string of pipe 
separated longs representing the epoch millis. In webobjects I would be able to 
individually map that single column to factory methods and convert them. In 
cayenne I see I’m supposed to use ValueObjectType (or extended types) but I 
encountered two issues:

Issue 1:
If I want to use List<LocalDateTime> as my value type I can’t return the 
generic part with getValueType(). And eliminating the generics would make it a 
useless raw type because it would then clash with any other list based 
conversion (i.e. List<String>, List<Duration> bla bla) that requires a 
different encoding/decoding mechanism.
One thing that came to mind would be to attempt using a LocalDateTime[].class 
and then having to converted to a List<LocalDateTime> elsewhere. Is this the 
only way to go? 

Issue 2:
What if my database has different columns holding the same data type but 
serialized in different ways? I was checking some very old code of mine that I 
was trying to port and I found that in one cases I had serialized a list of 
strings as pipe separated and then somewhere else another list of strings as 
comma separated. How would one go to define different deserialization schemes 
for the same List<String> object. One based on a specific column of the 
database?

Thank you in advance for any support,
Riccardo De Menna

Reply via email to