Hibernate mapping <many-to-one>

Discussion in 'Java' started by Sachin, Jul 7, 2008.

  1. Sachin

    Sachin Guest

    In the mapping file following section is there for the class
    GroupPage.

    <many-to-one name="BusinessUnit"
    class="BusinessUnit"
    access="nosetter.camelcase-underscore"
    not-null="true"/>

    But there is no attibute of a collection of <BusinessUnit> in the
    mapped class, but the relational table has a BusinessUnit column.

    Can this becomes a problem when persisting objects of GroupPage ?

    Actually the class and the mapping file is written by another party, I
    am new to hibernate and really value your suggestions.
    Sachin, Jul 7, 2008
    #1
    1. Advertising

  2. Sachin

    Daniel Pitts Guest

    Sachin wrote:
    > In the mapping file following section is there for the class
    > GroupPage.
    >
    > <many-to-one name="BusinessUnit"
    > class="BusinessUnit"
    > access="nosetter.camelcase-underscore"
    > not-null="true"/>
    >
    > But there is no attibute of a collection of <BusinessUnit> in the
    > mapped class, but the relational table has a BusinessUnit column.
    >
    > Can this becomes a problem when persisting objects of GroupPage ?
    >
    > Actually the class and the mapping file is written by another party, I
    > am new to hibernate and really value your suggestions.

    Many-to-one is the same as a backward one-to-many. Remember, relations
    go both ways, where Object References don't have to.

    It is okay to put the foreign key column in the other table, rather than
    create a mapping table, since the table doesn't have to correspond
    directly to the object structure. They *are* different paradigms after all.

    Hmm, now that I read your post more closely, it could be that the
    BusinessUnit has a collection of GroupPages, but I would *think* the
    mapping should be one-to-many from the BusinessUnit

    If it works, don't fix it :)
    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
    Daniel Pitts, Jul 7, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Igor
    Replies:
    6
    Views:
    29,933
  2. Mirko
    Replies:
    0
    Views:
    2,288
    Mirko
    Oct 12, 2006
  3. Michael Plate

    question to many-to-many of hibernate

    Michael Plate, May 8, 2007, in forum: Java
    Replies:
    0
    Views:
    349
    Michael Plate
    May 8, 2007
  4. Piotre Ugrumov
    Replies:
    0
    Views:
    2,175
    Piotre Ugrumov
    Jun 16, 2009
  5. snehasish
    Replies:
    0
    Views:
    1,612
    snehasish
    Oct 27, 2009
Loading...

Share This Page