PK and relationships

17 views
Skip to first unread message

Anthonin Lizé

unread,
Oct 14, 2021, 5:24:14 AM10/14/21
to Agrest Framework User Group
Hello,

I originally reverse engineered an Oracle DB. My numeric fields being of type NUMBER, the datamap contained NUMERIC DB type and then BigDecimal Obj type. Especially for ID PKs.
Now, when trying to save an object, I got an exception saying that cayenne was not able to cast the generated PK (Integer) to the object field type (BigDecimal). I converted then all the ID PKs to Integer and adapted the relationships.

The thing is now, that AgRest does not seem to output related objects in the JSON output.
Related objects appear as null and many to many as empty arrays.
But the converted PK of the root object displays properly.
It all work again when switching back to BigDecimal.
I tried with BigInteger, it does not work. I tried Integer and also DB type INTEGER instead of NUMERIC, still nothing. It would only work with BigDecimal.

I checked the fetched cayenne entity, it contains the related entities. Even the returned DataResponse contains them. It seems to happen after, when serializing to JSON.
The only logs I can get from AgRest are those lines for the root entity and related entities:
DEBUG io.agrest.cayenne.compiler.CayenneAgEntityCompiler - compiling Cayenne entity for type: <...>

Any thoughts on this? Could there be some remnants of the BigDecimal somewhere? I checked the datamap, all clear. But I might have missed something.

Thank you.
Anthonin

Anthonin Lizé

unread,
Oct 14, 2021, 5:42:16 AM10/14/21
to Agrest Framework User Group
Me again... of course I solve it just after sending a message after hours on it! haha

So... I had to convert as well all (concerned) DB entity fields from NUMERIC to INTEGER, not only the ones I was testing. Or maybe I tested wrongly before.
But it comes from there. The link between the java type and DB type.

Thanks anyway.
Anthonin

Andrus Adamchik

unread,
Oct 21, 2021, 6:21:23 AM10/21/21
to Agrest Framework User Group
Hi Anthonin,

Yeah, great to hear you solved it on your own :) 

Yeah, the NUMERIC type in Oracle has always been a source of confusion for the tools back in my Oracle days.

Andrus

--
You received this message because you are subscribed to the Google Groups "Agrest Framework User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agrest-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/agrest-user/4bfcc6e0-8bfe-4961-b9c0-205a0b911103n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages