[odb-users] collection mapping error

c.sell at byterefinery.de c.sell at byterefinery.de
Wed Mar 8 06:41:43 EST 2017


Hello,

so, I've done my reading, for the record. NULL value sematics are  
indeed documented. Assuming not-null semantics for values is a  
conceptual decision, which is also documented and circumventable  
(odb::nullable etc.)

the fact that the exception states "object already persistent" rather  
than "constraint violation" remains misleading.

the fact that the is_null parameter in the set_image function of  
value_traits implementations should be used with caution might deserve  
mentioning. All examples simply set it to false, and never say why.

Apart from the above, the more I read into ODB, the more impressed I  
am. Beautiful software, very capable and quite well documented. I  
wrote a pretty complete O/R mapper for Smalltalk almost 20 years ago  
and know the Java bunch (Hibernate, JPA). So I feel I can make that  
statement (and some others)

regards,
Christian

Zitat von c.sell at byterefinery.de:

> Hi Boris,
>
>> Right, since std::vector<> has no notion of a NULL value.
>
> It is your choice to represent an empty vector<char> by an empty  
> byte sequence. It was my choice to represent an empty image by a  
> NULL value. This is only dealing with how they are stored, the  
> collection that holds them still sees the empty value
>
>> None of this is correct/makes sense. But I hope the above explanations
>> will help (if not, please read the manual; we both could have saved a
>> lot of time if you did so from the beginning).
>
> Sorry, but I dont see how reading the manual would have helped. I  
> was faced with an error message stating "object already persistent",  
> when in fact it was a constraint violation caused by a non-obvious  
> (and undocumented) interdependence between the default data model  
> (NOT NULL constraints on collection value columns) and the traits  
> implementation (which should not set the NULL marker if used with  
> the default data model).
>
> I suggest an amendment to the documentation that points to the fact  
> that the default data model for collections imposes NOT NULL  
> constraints (I may have overread that). And maybe even some hint on  
> how to deal with is_null in traits implementations (I dont think I  
> overread that, I searched thoroughly for docs and only found a  
> reference to sample code).
>
> Anyway, not an issue, this is a free lunch. I just don't want to  
> "not make sense".
>
> May I still take you up on your offer regarding the pre-release  
> build for windows?
>
> regards,
> Christian




More information about the odb-users mailing list