Hi Flo
1. Do you have a single session scope spanning the read and save operations?
If there is no shared 1st level cache, NH assumes it has to update the
entity.
2. Are you using IDENTITY fields?

-Markus

2009/4/29 Flominator <[email protected]>

>
> Hi Markus,
>
> thanks for your reply. I will try it, although my boss has his doubts,
> since the domain logic requires it the other way round.
>
> We have profiled the application with NHibernate Profiler. This causes
> us to ask two questions:
>
> 1. Why does someChannel.Save() result in an update query if it's
> properties have not been changed? ok, the collection has changed, but
> we deactivated cascading, so there should be no update, right?
>
> Is this because we decided to use AR mediator instead of inheriting
> from AR base?
>
>
> 2. Why do the Measurands not know the ID of the channel they belong
> to, even though they're saved after adding them? Is this intended
> behavior of HasMany?
>
> Could it really be intended to execute an INSERT query after adding
> and saving the measurand, followed by saving the channel causing
> UPDATEs to channel and measurand?
>
> Could your suggestion maybe solve these problems?
>
> Thanks for your patience,
>
> Flo
>
> On 21 Apr., 14:08, Markus Zywitza <[email protected]> wrote:
> > Hi Flo,
> >
> > if I understood the problem correctly, Measurand is a "value type"
> without a
> > reference to the Channel entity it belongs to. I set value type into
> quotes
> > because I don't believe that they qualify for a value type. I rather
> think
> > it should be an entity in the channel aggregate.
> >
> > Anyway, Measurands have an implicit many-to-one-relation to Channel. You
> can
> > avoid the error above if you make this an explicit relation. Instead of
> > using HasMany on Channel, use BelongsTo on Measurand.
> > To display some measurands of a given channel, you should implement a
> method
> > like this in the Channel class:
> > public IEnumerable<Measurand> GetMeasurands(DateTime from, DateTime to)
> > {
> >   return new SimpleQuery<Measurand>("from Measurand m where m.Channel = ?
> > and SampleDate between ? and ?", this.Id, from, to).Execute();
> >
> > }
> >
> > -Markus
> >
> > 2009/4/21 Flominator <[email protected]>
> >
> >
> >
> > > What do I have left after removing HasMany?
> > > Is there any documentation on this?
> >
> > > On Apr 21, 10:18 am, Ayende Rahien <[email protected]> wrote:
> > > > Not if you have a collection of them.Remove the HasMany, basically
> >
> > > > On Tue, Apr 21, 2009 at 11:13 AM, Flominator <[email protected]>
> > > wrote:
> >
> > > > > Isn't this solution one directional?
> >
> > > > > On Apr 21, 10:10 am, Ayende Rahien <[email protected]> wrote:
> > > > > > Remove the collection, make the association one directional
> >
> > > > > > On Tue, Apr 21, 2009 at 11:05 AM, Flominator <
> > > [email protected]>
> > > > > wrote:
> >
> > > > > > > What should it be then?
> >
> > > > > > > On Apr 21, 9:47 am, Ayende Rahien <[email protected]>
> wrote:
> > > > > > > > Flominator,A collection that large shouldn't be a collection
> >
> > > > > > > > On Tue, Apr 21, 2009 at 10:42 AM, Flominator <
> > > > > [email protected]>
> > > > > > > wrote:
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to