When we have a class:
@Entity Order implements Serializable { @Id private Integer id; ... }
and:
@Entity OrderLine implements Serializable { @Id private Integer id; @ManyToOne Order order; ... }
What row name will the property order map to?
order_id, ORDER_ID or Order_id?
(ommiting the @JoinColumn(name='order_id') is deliberate)
Unidirectional @OneToMany with @JoinColumn.
In JPA a ManyToOne relationship is specified through the @ManyToOne annotation or the <many-to-one> element. A @ManyToOne annotation is typically accompanied by a @JoinColumn annotation. The @JoinColumn annotation specifies how the relationship should be mapped to (expressed in) the database.
Create an entity class Student. java under com. javatpoint. mapping package that contains student id (s_id), student name (s_name) with @OneToMany annotation that contains Library class object of List type.
I might not understand your question. However, don't you need something like below?
@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="order_id", nullable=false) Order order;
here are some examples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With