EF too. On Fri, Oct 1, 2010 at 7:27 AM, Diego Mijelshon <[email protected]>wrote:
> All modified entities are updated when the session is flushed. That's just > how NH works. > > Diego > > > > On Fri, Oct 1, 2010 at 01:45, alexey_baranov <[email protected]> wrote: > >> Hi! >> >> Sorry for my poor english again. Sometimes I may write something else >> then want to say. Let me try again. I'l try to explain my point. As >> we understand cascade= "Save-update, persist" will save transient >> refferenced entities as we need. >> >> ISession.Save(transientEntity); //persisting refferenced transient >> entities >> >> That's OK. >> >> And it will command to update refferenced persisted entities when >> doing so >> >> ISession.Update(persistedEntity); //updating refferenced persisted >> entities >> >> This is little more then we need in out case. >> >> I'm trying to ask may we configure NHibernate for saving transient >> entities WITHOUT auto updating persisted entities? >> Another word can we write cascade="save-update, but only when >> refferenced entity is transient"? >> >> Thanks! >> >> On Sep 30, 6:09 pm, Fabio Maulo <[email protected]> wrote: >> > well... it depend on which method you will use. >> > btw don't say "We do not like save-update feature" if you want work the >> way >> > you have described. >> > >> > On Thu, Sep 30, 2010 at 9:05 AM, alexey_baranov <[email protected]> >> wrote: >> > > OK. We do not like "save-update" feature. May we set just default- >> > > cascade="persist" ? >> > >> > > Thanks! >> > >> > > On Sep 30, 5:27 pm, Fabio Maulo <[email protected]> wrote: >> > > > What you have to do is set default-cascade="save-update, persist" at >> the >> > > top >> > > > of each mapping. >> > > > I don't like it at all but you know what you need. >> > >> > > > On Thu, Sep 30, 2010 at 6:26 AM, alexey_baranov <[email protected] >> > >> > > wrote: >> > > > > I'm not sure understand what you ask, But I'l try >> > >> > > > > We have a code where Obj inherited classes (Request, Person, >> Client, >> > > > > Network....) returns like base Obj type (Everything is Obj in out >> > > > > solution/ Like in AD, LDAP or other catalog) >> > >> > > > > And we have many many views for each entity type. Like >> > > > > NetworkEquipmentView, ClientView, FolderView, PersonView, .... >> > >> > > > > class ObjView: UserControl{ >> > > > > Obj Model(){ >> > > > > set <...} >> > > > > get { >> > > > > ... >> > > > > return _model; >> > > > > } >> > > > > } >> > > > > } >> > >> > > > > Now imagine user click "Save" button. We get Obj refference to >> View's >> > > > > model (but we do not know what type exactly) and need to save it. >> > >> > > > > var model= SomeView.Model; //hire we have any Obj for example >> Person. >> > > > > Sometimes it refference to new Entity. Mayby it refference to >> > > > > transient Parent, mayby it refference to transient Attachment, >> mayby >> > > > > model is not a Peston but File at all >> > > > > session.Save(model); //and hire we want to save all unsaved >> > > > > refferenced entities before saving model. But have Exception >> "unable >> > > > > to save entity, save unsaved referenced entity first" >> > >> > > > > what we have to do hire is to check model type and then chek is >> > > > > refference properties transient or not like this >> > >> > > > > if (model is Folder){ >> > > > > if (model have unsaved attachments){ >> > > > > save unsaved attachments >> > > > > } >> > > > > } >> > > > > else if (model is Request){ >> > > > > if (model have unsaved initier){ >> > > > > save initier >> > > > > } >> > > > > if (model have unsaved doers){ >> > > > > save unsaved doers >> > > > > } >> > > > > if (model have unsave .....) >> > > > > } >> > > > > else if (.... >> > > > > ..... >> > > > > } >> > > > > esle if >> > > > > else if >> > > > > ..... >> > > > > .... >> > > > > } >> > >> > > > > We have many other places where we got returned polimorphoc entity >> > > > > like base class Obj >> > > > > Hope you understand me >> > >> > > > > Thanks! >> > >> > > > > <?xml version="1.0" encoding="utf-8" ?> >> > > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> > > > > assembly="Helpdesk" namespace="Helpdesk"> >> > > > > <class name="Obj" discriminator-value="9"> >> > > > > <id name="Id"> >> > > > > <generator class="native" /> >> > > > > </id> >> > > > > <discriminator column="Typee" type="Int32"/> >> > > > > <timestamp name="Modifed"/> >> > > > > <property name="Path" access="nosetter.camelcase-underscore" >> not- >> > > > > null="true"/> >> > > > > <property name="Name" column="Namee" not-null="true"/> >> > > > > <property name ="IsFolder" >> access="nosetter.camelcase-underscore"/ >> > >> > > > > <property name="Note"/> >> > > > > <property name="Created" not-null="true"/> >> > > > > <many-to-one name="Owner" column ="Ownerr" /> >> > > > > <many-to-one name ="Parent" >> access="nosetter.camelcase-underscore"/ >> > >> > > > > <set name="Children" inverse="true"> >> > > > > <key column="Parent"/> >> > > > > <one-to-many class="Obj"/> >> > > > > </set> >> > > > > <set name="Attachments" table="Obj_Attachments" cascade="save- >> > > > > update"> >> > > > > <key column="Obj"/> >> > > > > <many-to-many column="Attachment" class="Filee"/> >> > > > > </set> >> > > > > </class> >> > > > > </hibernate-mapping> >> > >> > > > > <?xml version="1.0" encoding="utf-8" ?> >> > > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> > > > > assembly="Helpdesk" namespace="Helpdesk"> >> > > > > <subclass name="Folder" extends ="Obj" discriminator-value="42"> >> > > > > <!--<join table="Folder"> >> > > > > <key column="Id"/> >> > > > > </join>--> >> > > > > </subclass> >> > > > > </hibernate-mapping> >> > >> > > > > <?xml version="1.0" encoding="utf-8" ?> >> > > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> > > > > assembly="Helpdesk" namespace="Helpdesk"> >> > > > > <subclass name="Request" extends ="Obj" discriminator-value="41"> >> > > > > <!--<join table="Request"> >> > > > > <key column="Id"/>--> >> > > > > <property name="Text" column="Textt"/> >> > > > > <property name="Deadline"/> >> > > > > <property name="Closed"/> >> > > > > <property name="CallbackOn"/> >> > > > > <many-to-one name ="Initier" fetch="join"/> >> > > > > <list name="Doers" table="Request_Doers"> >> > > > > <key column="Request"/> >> > > > > <index column="i"/> >> > > > > <many-to-many column="Doer" class="Department"/> >> > > > > </list> >> > > > > <!--</join>--> >> > > > > </subclass> >> > > > > </hibernate-mapping> >> > >> > > > > <?xml version="1.0" encoding="utf-8" ?> >> > > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> > > > > assembly="Helpdesk" namespace="Helpdesk"> >> > > > > <subclass name="Note" extends ="Obj" discriminator-value="63"> >> > > > > <!--<join table="Note"> >> > > > > <key column="Id"/>--> >> > > > > <property name="Text" column="Textt"/> >> > > > > <!--</join>--> >> > > > > </subclass> >> > > > > </hibernate-mapping> >> > >> > > > > .... >> > > > > ... >> > > > > ... >> > > > > ... >> > >> > > > > On Sep 29, 4:15 pm, Fabio Maulo <[email protected]> wrote: >> > > > > > A little graph with your mapping. >> > >> > > > > > On Wed, Sep 29, 2010 at 5:20 AM, alexey_baranov < >> [email protected]> >> > > > > wrote: >> > > > > > > I'm not shure understand you. What is this "save-update, >> persist" ? >> > > Is >> > > > > > > it existed feature or just the abbreviation for our wish? I >> have >> > > never >> > > > > > > see "persist". We do not need cascade "save-update, persist", >> just >> > > > > > > "persist". >> > >> > > > > > > I can share any mapping information you need. This is not a >> big >> > > > > > > seecret. What does exactly you ask? Mapping files? code >> listing or >> > > > > > > litle example? >> > >> > > > > > > Thanks! >> > >> > > > > > > On Sep 29, 3:30 am, Fabio Maulo <[email protected]> wrote: >> > > > > > > > I would say that what you are looking for is >> > > > > > > default-cascade="save-update, >> > > > > > > > persist" but I would be sure. >> > >> > > > > > > > If the question will not sound "rude" (today was again >> another of >> > > > > those >> > > > > > > day, >> > > > > > > > in public and privately), >> > >> > > > > > > > can you show us an example ? >> > >> > > > > > > > A little graph with your mapping. >> > >> > > > > > > > On Tue, Sep 28, 2010 at 1:11 PM, alexey_baranov < >> > > [email protected]> >> > > > > > > wrote: >> > > > > > > > > Hi! >> > >> > > > > > > > > We have to implement new method SaveGraph(), wich will be >> like >> > > > > > > > > original ISession.Save() except automatic saving >> refferenced >> > > > > transient >> > > > > > > > > entities insted throwin exception.We need this feature in >> many >> > > > > cases >> > > > > > > > > when working with polimorphic entities and do not know >> exactly >> > > what >> > > > > > > > > type is used. We ask more experienced users and developers >> > > voice is >> > > > > it >> > > > > > > > > feasible work. >> > >> > > > > > > > > Thanks. >> > >> > > > > > > > > -- >> > > > > > > > > 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]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > > > > > . >> > > > > > > > > For more options, visit this group at >> > > > > > > > >http://groups.google.com/group/nhusers?hl=en. >> > >> > > > > > > > -- >> > > > > > > > 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]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > > > . >> > > > > > > For more options, visit this group at >> > > > > > >http://groups.google.com/group/nhusers?hl=en. >> > >> > > > > > -- >> > > > > > 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]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > <nhusers%[email protected]<nhusers%[email protected]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > >> > > > > . >> > > > > For more options, visit this group at >> > > > >http://groups.google.com/group/nhusers?hl=en. >> > >> > > > -- >> > > > 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]> >> <nhusers%[email protected]<nhusers%[email protected]> >> > >> > > . >> > > For more options, visit this group at >> > >> > ... >> > >> > read more ยป >> >> -- >> 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=en. >> >> > -- > 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=en. > -- 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.
