开发者

JPA2 annotations for uni-directional relationship

Hello

In the InstrumentConfig class detailed below what JPA2 annotations should instrument and market have?

开发者_StackOverflow社区

Thanks

@Entity
@Access(AccessType.FIELD)
class Instrument {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    long id;

    @Basic
    String code; // EURCHF, GOOG, etc.
}

@Entity
@Access(AccessType.FIELD)
class Market {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    long id;

    @Basic
    String name;
}

@Entity
@Access(AccessType.FIELD)
class InstrumentConfig {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    long id;

    // what JPA2 annotations should instrument and market have?
    Instrument instrument;
    Market market;

    @Basic
    String dataURL
}


In the simpliest case it's just this (foreign key columns are named by default, no cascading, etc):

@ManyToOne
Instrument instrument;     
@ManyToOne
Market market; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜