Page 280, which says:
JPA does not support unidirectional one to many relationships using a foreign key on the target table and you cannot use the following mapping if you have a unidirectional one to many relationship between Item and Bid:
preotected Set<Bid> bids;
Can you tell what it means?
For the ones that might be interested, I am copying the relevant extract from the specs (section 9.1.24 OneToMany Annotation):
The default schema-level mapping for unidirectional one-to-many relationships uses a join table, as described in Section 18.104.22.168. Unidirectional one-to-many relationships may be implemented using one-to-many foreign key mappings, however, such support is not required in this release. Applications that want to use a foreign key mapping strategy for one-to-many relationships should make these relationships bidirectional to ensure portability.
I am new to JPA and i have a question about the OneTOMany unidirectional mapping. Let we assume the following example two entities
Person (ID, NAME) and Car (ID, CAR_NAME, PER_ID) i.e the foreign key is in the target table.
Here is my relationship mapping inside the Person entity;
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "CAR",
joinColumns = @JoinColumn(name = "PER_ID"),
inverseJoinColumns = @JoinColumn(name = "ID"))
private List<Car> cars;
Note this is an unidirectional OneToMany mapping from Person to Car. I am using Eclipselink and the above mapping is always not working . Sometimes system throws the exception and says CAR_ID is not found.
If any of you came similar issue please share your idea. Much appreciate your reply.