Pardon the primary key has nothing to do with it, only the forreign key. The
primary key is just an identity.

On Thu, Nov 19, 2009 at 3:07 PM, Mikael Henriksson <[email protected]>wrote:

> Ok I am terrible at explaining but here goes: You know how you have
> counters id columns (incremental identity). The version would be the
> incremental identity for the specific primary-key and foreign-key. So for
> every insert where the parent_id and the parent_version_id already exists it
> should autoincrement so this time around it would be more of a conditional
> counter I suppose.
>
> On Thu, Nov 19, 2009 at 2:55 PM, Fabio Maulo <[email protected]> wrote:
>
>> What mean "Version" (that is for optimistic-lock) in a no mutable entity ?
>>
>> 2009/11/19 Mikael Henriksson <[email protected]>
>>
>>> Ok the following works like a fucking charm (pardon the language) except
>>> that since I only do inserts it does not update the version automatically
>>> and I'd rather not leave that to whoever is writing the persistence service
>>> ;)
>>> Any suggestions to how I can intercept and automatically increment the
>>> version where contact_id = ? and contact_version_id = ?. Do I need to use
>>> the event subsystem for that? Or can I solve it further in the mapping?
>>> Note: ( ReadOnly() means "mutable=false" which prohibits deletes and
>>> updates.)
>>>
>>> public class ParentMap : ClassMap<Parent>
>>> {
>>>     public ParentMap()
>>>     {
>>>         Table("parent_def");
>>>         Id(x => x.Id,"parent_id");
>>>         Map(x => x.UID, "parent_uid").CustomSqlType("varchar").Length(40);
>>>         Map(x => x.DeletedAt ,"dte_deleted").Nullable();
>>>         Map(x => x.ModifiedAt, "dte_modified").Nullable();
>>>         Map(x => x.CreatedAt, "dte_created").Nullable();
>>>         Map(x => x.AutoUpdate, "auto_update").CustomSqlType("bit");
>>>
>>>         HasMany(x => x.ParentVersions)
>>>             .KeyColumn("parent_id")
>>>             .Inverse()
>>>             .Cascade.All();
>>>     }
>>> }
>>>  public class ParentVersionMap : ClassMap<ParentVersion>
>>> {
>>>     public ParentVersionMap()
>>>     {
>>>         Table("parent_version");
>>>         *ReadOnly();*
>>>
>>>         Id(x => x.Id  ,"parent_version_id");
>>>         Version(x => x.Version)
>>>             .Column("parent_version")
>>>             .Generated.Never();
>>>         Map(x => x.ParentHash ,"parent_hash")
>>>             .CustomSqlType("varchar")
>>>             .Length(40);
>>>         Map(x => x.DateCreated ,"dte_created");
>>>         Map(x => x.UpdateAvailable, "update_available");
>>>
>>>         References(x => x.Parent, "parent_id")
>>>             .ForeignKey("parent_id");
>>>     }
>>> }
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "nhusers" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<nhusers%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/nhusers?hl=.
>>>
>>
>>
>>
>> --
>> Fabio Maulo
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=.
>>
>
>

--

You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=.


Reply via email to