1

I'm trying to save persistent object through Cayenne interface:

ServerRuntime runtime = new ServerRuntime("cayenne.xml");
...
DataContext context = (DataContext)runtime.getContext();
ObjectWithArray owa = context.newObject(ObjectWithArray.class);
owa.setArray(new Double[] {1.0, 2.0});
context.commitChanges();

With this variant the corresponding table field stores after saving some strange string like

aced0005757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c020000787000000002740003312e30740003322e300000000000000000

and not somthing like ({1.0,2.0}). If I use sql array type instead of Double[] it won't save throwing a non serializable exception.

Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
DrDecay
  • 59
  • 1
  • 10
  • Strange String is likely a serialized value of the array. But I'll need to doublecheck on the array attributes support. – andrus_a Feb 02 '15 at 15:44
  • Just did some research: https://issues.apache.org/jira/browse/CAY-1985 and got a bit different error on Cayenne 4.0. Still ARRAY support seems to be broken. You can track Jira ticket per link above to see when the fix is available. – andrus_a Feb 03 '15 at 22:30
  • Thanks for reply. I found that using hsqldb solves the problem. It saves double array converted into extended java.sql.Array type. – DrDecay Feb 04 '15 at 10:08
  • A question to andrus_a: you said that had gotten slightly different results on Cayenne 4.0, but there is only 3+ version available, or I am mistaken?! – DrDecay Feb 10 '15 at 07:19
  • 3.2 was renamed to 4.0. 4.0.M2 release is upcoming. – andrus_a Feb 24 '15 at 11:21

0 Answers0