Hibernate mapping <many-to-one>

S

Sachin

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

Daniel Pitts

Sachin said:
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 :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top