How do I specify the foreign key on a many-to-one relationship when is not a property on the object

Posted by jjujuma on Stack Overflow See other posts from Stack Overflow or by jjujuma
Published on 2010-04-26T19:55:14Z Indexed on 2010/04/26 20:13 UTC
Read the original article Hit count: 177

Filed under:
|
|

I'm trying to map a many-to-one relationship from MarketMenuBranch to Market. My classes look like:

public class Market implements Serializable {
    private int id;
    private String name;
    private List<MarketMenuBranch> marketMenuBranches;
    // accessors / mutators etc...

public class MarketMenuBranch implements Serializable {
    private MarketMenuBranchId id;
    private String name;
    // accessors / mutators etc...

public class MarketMenuBranchId implements Serializable {
    private int marketId;
    private int sequence;
   // accessors / mutators etc...

But I don't know what I can put for the property name (where I have ???? below). I really want to put id.marketId but that seems to be wrong.

<class name="MarketMenuBranch" table="MARKET_MENU_BRANCH">
    <composite-id name="id" class="MarketMenuBranchId">
        <key-property name="marketId"/>
        <key-property name="sequence"/>
    </composite-id>
    <property name="name"/>
    <many-to-one name="????????"/>
</class>

How can I do this?

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate