Cool idea, I will definitely test that, and then I can use the
discriminator to sort in my hql or criterion? :)

On Jul 30, 4:33 pm, Fabio Maulo <[email protected]> wrote:
> <subclass><join>
>
> 2009/7/30 Niclas Pehrsson <[email protected]>
>
>
>
>
>
> > The only difference between version and my way is that version is not
> > dependent on the object/row version but if a object is changed and
> > saved it would't go from version 5 to 6 but it would look what has the
> > last object changed version and increment it by 1 so it could be from
> > 5 to 17.
>
> > Yeah its kind of an discrimator that I can sort on when makes my
> > reqiest, can I have that even if I use joined subclasses?
>
> > On 30 Juli, 14:15, Fabio Maulo <[email protected]> wrote:
> > > I don't know what you are doing but   <property name="Version"
> > > type="System.Int64" not-null="true" />
> > >    <property name="OrderPriority" type="System.Int32"
> > > insert="true" update="true"/>
> > > sound as
> > > <version>
> > > <discriminator>
>
> > > 2009/7/30 Niclas Pehrsson <[email protected]>
>
> > > > I know it sounds kind of awkward.
> > > > But I'm want to have a field in the database that's only is used for
> > > > searching, and when insert I want to be able set that value, the value
> > > > will tell which type of entity that it represent so I can use an sort
> > > > on it. Right now I have an interface that tells that this domainobject
> > > > is synchronizable, (I sync between to databases one way), on the
> > > > serverside.
>
> > > >  <class name="ISynchronizable" table="SynchronizableItems">
> > > >    <id name="Id" type="System.Guid">
> > > >      <generator class="assigned" />
> > > >    </id>
> > > >    <property name="Version" type="System.Int64" not-null="true" />
> > > >    <property name="OrderPriority" type="System.Int32" insert="true"
> > > > update="true"/>
> > > >    <joined-subclass name="Employee">.....
> > > >    <joined-subclass name="Article">....
> > > >    <joined-subclass name="Organization">....
> > > >  </class>
> > > > </hibernate-mapping>
>
> > > > In the IInterceptor when an transaction starts I found out which is
> > > > the current highest versionnumber and adds one in the
> > > > GetNewVersionNumber method
>
> > > >     public override void AfterTransactionBegin(ITransaction tx)
> > > >        {
> > > >            _currentVersionNumber = GetNewVersionNumber();
> > > >            base.AfterTransactionBegin(tx);
> > > >        }
>
> > > > Now in OnSave I set the version, but because my other question here on
> > > >http://groups.google.se/group/nhusers/browse_thread/thread/f7195afd95.
> > ..
> > > > when I later retreive the objects they comes unordered so if the
> > > > entities has dependencies to each other in other words they need to be
> > > > saved in correct order to not cause a foreignkey exception I need them
> > > > to come in table order.
> > > >        public override bool OnSave(object entity, object id, object[]
> > > > state, string[] propertyNames, IType[] types)
> > > >        {
> > > >            if (entity is ISynchronizable)
> > > >            {
> > > >                SetVersion(state, propertyNames,
> > > > _currentVersionNumber);
> > > >                SetOrderPriority(entity, state, propertyNames);
> > > >                return true;
> > > >            }
> > > > }
> > > >        private const string OrderPropertyName = "OrderPriority";
> > > >        private void SetOrderPriority(object entity, object[] objects,
> > > > string[] strings)
> > > >        {
> > > >            if(entity is Employee)
> > > >            {
> > > >                objects[GetPropertyIndexForPropertyName(strings,
> > > > OrderPropertyName)] = 1;
> > > >                return;
> > > >            }
> > > >            if (entity is Article)
> > > >            {
> > > >                objects[GetPropertyIndexForPropertyName(strings,
> > > > OrderPropertyName)] = 2;
> > > >                return;
> > > >            }
> > > >            if (entity is Organization)
> > > >            {
> > > >                objects[GetPropertyIndexForPropertyName(strings,
> > > > OrderPropertyName)] = 3;
> > > >                return;
> > > >            }
> > > > }
>
> > > > Now when having that said, I really do not need the OrderPriority
> > > > property in my domainmodel, only need to set it in the interceptor :)
> > > > but with your earlier answer I guess its not possible.
> > > > I guess it would be nice to have it if I would have an extra field
> > > > that tells me who have made the change but I only want it persisted in
> > > > the db and not it my model.
>
> > > > On 29 Juli, 23:34, Fabio Maulo <[email protected]> wrote:
> > > > > Interesting concept.An insertable/*updatable* property but not in the
> > > > model,
> > > > > very interesting.
> > > > > Which is the name of the pattern ?
>
> > > > > 2009/7/29 Niclas Pehrsson <[email protected]>
>
> > > > > > is there any alternative what Im is out for,
>
> > > > > > use the field as select/insert/update but not in the model?
> > > > > > So I just can access i from IInterceptor :).
>
> > > > > > On Jul 29, 8:42 pm, Fabio Maulo <[email protected]> wrote:
> > > > > > > access="none" mean that the property does not involved in insert
> > nor
> > > > > > update
> > > > > > > but only in where clauses of queries.
>
> > > > > > > 2009/7/29 Niclas Pehrsson <[email protected]>
>
> > > > > > > > I I have tested to inherit EmptyInterceptor and registered it
> > with
> > > > the
> > > > > > > > sessionfactory.
> > > > > > > > In OnSave I want to add value to an property that has
> > access="none"
> > > > > > > > but I can set the values in OnSave...
>
> > > > > > > > states[GetIndexForProperty("MyAccessNonePropertyName")] =
> > false;
>
> > > > > > > > <property name="MyAccessNonePropertyName" type="System.Boolean"
> > > > > > > > access="none"/>
>
> > > > > > > > But it keeps getting the value null when inserting or updating,
> > it
> > > > > > > > works fine if I have something else on access. Am I doing
> > something
> > > > > > > > wrong?
>
> > > > > > > --
> > > > > > > Fabio Maulo
>
> > > > > --
> > > > > Fabio Maulo
>
> > > --
> > > Fabio Maulo
>
> --
> 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]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to