开发者

JPA2 annotations for uni-directional relationship

开发者 https://www.devze.com 2023-02-14 06:12 出处:网络
Hello In the InstrumentConfig class detailed below what JPA2 annotations should instrument and market have?

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

精彩评论

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