Use a DTO or a serialization library that you can customize (i.e. tell it to
serialize PersonAddress.Person.Id instead of going deep into Person)

   Diego


On Tue, Apr 27, 2010 at 11:36, Yauhen <[email protected]> wrote:

> Serialization to javascript
>
> On Apr 27, 5:33 pm, Diego Mijelshon <[email protected]> wrote:
> > Yes. And I still don't see why that would be a problem.
> >
> >    Diego
> >
> >
> >
> >
> >
> > On Tue, Apr 27, 2010 at 11:28, Yauhen <[email protected]> wrote:
> > > so no way without bidirection?
> > > And this is the only correct and POSSIBLE way?
> >
> > > On Apr 27, 5:23 pm, Diego Mijelshon <[email protected]> wrote:
> > > > This is documented in 6.4. One-To-Many
> > > > Associations<
> > >http://nhforge.org/doc/nh/en/index.html#collections-onetomany>
> > > > (last
> > > > paragraph).
> > > > Also, you DON'T need to select Person fields when querying
> PersonAddress.
> > > > Where did you get that idea?
> > > > <many-to-one/> is lazy by default.
> >
> > > >    Diego
> >
> > > > On Tue, Apr 27, 2010 at 11:17, Yauhen <[email protected]> wrote:
> > > > > 1) PersonAddress.PersonId not nullable in the DB. Could not be
> > > > > changed. Backward compatibility
> > > > > 2) most of the queries are slq-queries not hql. so i don't want to
> > > > > select all person info when selecting just person address. I really
> > > > > don't want it.
> > > > > sql-queries are used due of a lot of secondary table references
> that
> > > > > are used for filtering of persons but for which I really don't need
> > > > > separate objects because they are not displayed anywhere. And
> didn't
> > > > > go somewhere outside of filtering.
> >
> > > > > So as I undertsand without separate object property to parent I
> could
> > > > > not do this?
> >
> > > > > On Apr 27, 5:12 pm, Diego Mijelshon <[email protected]>
> wrote:
> > > > > > Yauhen,
> >
> > > > > > Your are basically trying really hard to do things in a wrong
> way.
> > > > > > Having a proper bidirectional relationship is the best way to
> > > maintain
> > > > > > cascading collections.
> > > > > > "Cyclic references" are not a problem, unless you are trying to
> > > > > > automatically serialize your domain entities (wrong).
> > > > > > If you absolutely don't want the Person reference and are willing
> to
> > > > > accept
> > > > > > two SQL statements (insert and update), plus having
> > > > > PersonAddress.PersonId
> > > > > > nullable in the DB, you can remove the property from
> PersonAddress
> > > > > > completely.
> >
> > > > > >    Diego
> >
> > > > > > On Tue, Apr 27, 2010 at 11:03, Yauhen <[email protected]>
> wrote:
> > > > > > > Hello All,
> >
> > > > > > > I have problems with cascading of children.
> >
> > > > > > > I want to map one to many objects Person
> > > > > > > and PersonAddress
> >
> > > > > > >    public class Person
> > > > > > >   {
> > > > > > >           public virtual int Id {get; set;}
> > > > > > >           public virtual string FirstName {get; set;}
> > > > > > >        public virtual ICollection<PersonAddress> PersonAddress
> {
> > > get;
> > > > > set;
> > > > > > > }
> > > > > > >   }
> >
> > > > > > >    public class PersonAddress
> > > > > > >    {
> > > > > > >          public virtual int Id {get; set;}
> > > > > > >          public virtual int PersonId {get; set;}
> > > > > > >        ...
> > > > > > >   }
> >
> > > > > > > I don't want to have person object property in address. It
> creates
> > > > > > > cyclic references and don't necessary for my application.
> >
> > > > > > > mapping file is like following:
> >
> > > > > > >        <class name="Person"  table="Persons" >
> > > > > > >                <id name="Id" type="Int32" column="PersonId">
> > > > > > >                        <generator class="identity"/>
> > > > > > >                </id>
> > > > > > >                <set name="PersonAddress" table="PersonAddress"
> > > > > lazy="true"
> > > > > > > fetch="join" outer-join="true" cascade="all-delete-orphan">
> > > > > > >                        <key column="PersonId"></key>
> > > > > > >                        <one-to-many class="PersonAddress"/>
> > > > > > >                </set>
> >
> > > > > > >        </class>
> >
> > > > > > >        <class name="PersonAddress"  table="PersonAddress" >
> > > > > > >                <id name="Id" type="Int32" column="Id">
> > > > > > >                        <generator class="identity"/>
> > > > > > >                </id>
> > > > > > >                <property name="PersonId" column="PersonId"
> > > > > type="Int32"/>
> > > > > > >                <property name="PhoneWork" column="PhoneWork"
> > > > > > > type="String"/>
> >
> > > > > > >        </class>
> >
> > > > > > > when trying to insert Person with person address I am receiving
> > > > > > > exception. Because it tries to insert PersonAddress with
> invalid id
> > > > > > > (default -1, 0, etc).
> >
> > > > > > > in samples that I have found it is specified back reference
> from
> > > child
> > > > > > > to parent
> > > > > > > <many-to-one. In my case I have't parent object and don't want
> it.
> > > > > > > Integer field could not be mapped.
> > > > > > > So is there way to do cascade insert without parent object?
> >
> > > > > > > --
> > > > > > > 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%252bunsubscr...@googlegroup­s.com>
> > > ­>
> > > > > <nhusers%[email protected]<nhusers%[email protected]>
> <nhusers%252bunsubscr...@googlegroup­s.com>
> > > <nhusers%252bunsubscr...@googlegroup­s.com>
> > > > > ­>
> > > > > > > .
> > > > > > > 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]>
> <nhusers%[email protected]<nhusers%[email protected]>
> ­>
> > > <nhusers%[email protected]<nhusers%[email protected]>
> <nhusers%252bunsubscr...@googlegroup­s.com>
> > > ­>
> > > > > .
> > > > > > For more options, visit this group athttp://
> > > > > 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]>
> <nhusers%[email protected]<nhusers%[email protected]>
> ­>
> > > <nhusers%[email protected]<nhusers%[email protected]>
> <nhusers%252bunsubscr...@googlegroup­s.com>
> > > ­>
> > > > > .
> > > > > 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]>
> <nhusers%[email protected]<nhusers%[email protected]>
> ­>
> > > .
> > > > For more options, visit this group athttp://
> > > 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]>
> <nhusers%[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 athttp://
> 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.
>
>

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