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; 
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论