To have it populated from the DB but not persisted, you should be able to
set insert="false" and update="false" on the <property> element in the
mapping.

On Wed, Oct 22, 2008 at 5:03 AM, Keith Bloom <[EMAIL PROTECTED]> wrote:

>
> Sorry for the confusion and I'm starting to come to the same
> conclusion that prices should be a class.
>
> For me this has now spun off in to an exploration to find out how a
> collection of composite-elements work in NH.  It would be great if I
> could have a property that NH populated from the database but left
> ignored when the writing back to the database.
>
>
> On 20 Oct, 11:41, Jason Meckley <[EMAIL PROTECTED]> wrote:
> > I'm confused now. you can set read-only access for the code by using
> > nosetter access types and still allowing NH to hydrate the object. if
> > you mean NH should not populate the element, than your class (not
> > component) is readonly (mutable = false) or you don't map the value in
> > NH. If the access is mapped in NH than it can read/write the value. It
> > wouldn't make sense to only write values with NH.
> >
> > On Oct 20, 4:29 am, Keith Bloom <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Jason,
> >
> > > Thanks for the idea but NHibernate still attempts to insert a value
> > > but this time in the field instead of the property.  I've also tried
> > > setting generated="always" but this is ignored.
> >
> > > Do you know if the property settings for composite-elements and
> > > classes are the same?
> >
> > > Thanks, Keith
> >
> > > On 17 Oct, 16:04, Jason Meckley <[EMAIL PROTECTED]> wrote:
> >
> > > > just set the access attribute to nosetter.camelcase or whatever
> naming
> > > > strategy you use.
> >
> > > > On Oct 17, 10:19 am, Keith Bloom <[EMAIL PROTECTED]> wrote:
> >
> > > > > Hello,
> >
> > > > > Does anyone know if this:
> >
> > > > > <class name="Holiday" table="holidays">
> > > > >   // ... Some properties ..
> >
> > > > >   <set name="Prices" table="Prices">
> > > > >       <composite-element class="Price">
> > > > >         <parent name="Holiday" />
> > > > >          <property name="Id" column="id" insert="false"
> update="true"/
> >
> > > > >          <property name="PricePerUnit"  />
> > > > >          <property name="UnitsFrom" />
> > > > >          <property name="UnitTo" />
> > > > >       </composite-element>
> > > > >     </set>
> > > > > </class>
> >
> > > > > or something along these lines, is possible?
> >
> > > > > The reason is I have a set of immutable prices in my model which is
> a
> > > > > combination of the price, units and the holiday. In the database
> the
> > > > > price row also gets a seeded Id.  It would be very useful to have
> this
> > > > > as a read only property but if I add it to the Price class
> NHibernate
> > > > > kindly attempts to but a value in it.
> >
> > > > > As a workaround I'm using the HashCode as a identifier but this
> feels
> > > > > like a hack.
> >
> > > > > Many thanks, Keith.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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