ORA-01790 when including entity with limited-length binary field
Posted: Thu 18 Jul 2013 18:46
Okay, so I encountered an issue that goes like this..
I have an entity (let's call it 'Root.') This root has many-to-many relationships with two other entities, one of which has a binary field with a max length of 16 bytes. If I query Root and .Include() both of the other entities, I get the error mentioned in the title (ORA-01790: expression must have same datatype as corresponding expression.)
After digging a little deeper, I think I found the problem. The way .Include is implemented, each entity is found, its values are placed in the relevant columns, and NULLs are placed into the columns that represent other entities. These NULL values are cast to match the column types from the actual entities. However, in this case, the cast is incorrect. The column that was generated on my entity with the binary field was RAW(16), but in the separate query segments for pulling values from other related entities (where it should be casting NULL as RAW(16) to match), it's casting a NULL value to BLOB. BLOB is not the same type as RAW(16), so it fails.
If I remove my max length rule, it generates that binary column as BLOB, and then everything works, which is my current workaround. That isn't desirable, though, as I think the BLOB datatype has some negative performance characteristics on small data.
On the other hand, if I hand-edit the generated query to cast as RAW(16) instead of casting to BLOB, that also works without modifying the table. So, if there's a setting or update or something that I can apply so that it works, that'd be preferred.
Any thoughts or advice would be appreciated - thanks!
(Also, a self-contained repro project is available. It's a bit on the large side, though
I have an entity (let's call it 'Root.') This root has many-to-many relationships with two other entities, one of which has a binary field with a max length of 16 bytes. If I query Root and .Include() both of the other entities, I get the error mentioned in the title (ORA-01790: expression must have same datatype as corresponding expression.)
After digging a little deeper, I think I found the problem. The way .Include is implemented, each entity is found, its values are placed in the relevant columns, and NULLs are placed into the columns that represent other entities. These NULL values are cast to match the column types from the actual entities. However, in this case, the cast is incorrect. The column that was generated on my entity with the binary field was RAW(16), but in the separate query segments for pulling values from other related entities (where it should be casting NULL as RAW(16) to match), it's casting a NULL value to BLOB. BLOB is not the same type as RAW(16), so it fails.
If I remove my max length rule, it generates that binary column as BLOB, and then everything works, which is my current workaround. That isn't desirable, though, as I think the BLOB datatype has some negative performance characteristics on small data.
On the other hand, if I hand-edit the generated query to cast as RAW(16) instead of casting to BLOB, that also works without modifying the table. So, if there's a setting or update or something that I can apply so that it works, that'd be preferred.
Any thoughts or advice would be appreciated - thanks!
(Also, a self-contained repro project is available. It's a bit on the large side, though