On 24 Jun 2014, at 11:50, Gunnar Morling <gunnar(a)hibernate.org> wrote:
Yes, today we don't.
But is there any reason for not using the value column name?
Not more that the ones I outlined in this thread.
In fact that's what my pending PR
https://github.com/hibernate/hibernate-ogm/pull/337 does for MongoDB. Right now it even
allows to work with different value column names for the same table (either in the same or
in different documents/records) but I plan to add a check disallowing this for the sake of
portability to stores with a fixed schema.
I don’t follow that one. A fixed schema would be fine here, just with two columns instead
of one, no?
2014-06-20 13:00 GMT+02:00 Emmanuel Bernard <emmanuel(a)hibernate.org>:
On 19 Jun 2014, at 14:54, Gunnar Morling <gunnar(a)hibernate.org> wrote:
>> valueColumnName is something that I elected no to use because NoSQL we bind to so
far do not have a strong schema. And at at given segmentColumnValue only correspond a
single value. It would come and bite me if someone for the same segment value had two
different value column names to differentiate two different sequence.
>>
>> Would it really bite you? I think e.g. MongoDB could perfectly handle this case
via two different fields for the two sequences in the same document/segment.
>
> @TableGenerator(
> name=“1”,
> table=“Seq_table”,
> pkColumnName=“key”,
> pkColumnValue=“1”,
> valueColumnName=“value1”
> )
> @TableGenerator(
> name=“2”,
> table=“Seq_table”,
> pkColumnName=“key”,
> pkColumnValue=“1”,
> valueColumnName=“value2”
> )
>
> The two definitions share the same options except for valueColumnName.
> The table is roughly as followed
>
> TABLE(Seq_table)
> key | value1 | value2
> 1 | 10 | 24
>
> What would be the MongoDB representation in your approach?
>
> It would look like this:
>
> {
> "_id" : 1,
> "value1" : 10,
> "value2" : 24
> }
>
> So you would get the different sequence values from different fields of that same
document. But I wouldn't recommend to do so due to the potential contention on that
single record. Thus I'd raise at least a warning during bootstrap. As it's not
portable to stores with a fixed schema, I'd rather not support it at all, though, and
raise an error.
Exactly. But that’s the thing, AFAIK we do *not* store it that way today as we don’t use
valueColumnName. So today we store it like this
{
“_id”: 1,
“sequence_value”: 10
}
so 10 and 24 has to both live at the same time in sequence _value.