Code:
@OneToMany(mappedBy="<collection_foreign_key_property>")
private Set<CollectionType> collection;
Put the above in your parent entity's class. You'll need to create a child entity class:
Code:
@Entity
@Table(name="<child_table_name>")
public class CollectionType {
@ManyToOne
@JoinColumn(name="<foreign_key_column>")
private ParentType parent;
}
The collection table name will be taken from <child_table_name> in your collection entity. The foreign key column name will be taken from <foreign_key_column> in your collection entity as well. In the above example, <collection_foreign_key_property> would be "parent" (the name of the private member in the CollectionType class).
Additionally, according to
Chapter 2. Entity Beans of the
Hibernate Annotations Reference Guide (scroll down to 2.2.5.3.2.2),
Code:
A unidirectional one to many using a foreign key column in the owned entity is not that common and not really recommended. We strongly advise you to use a join table for this kind of association (as explained in the next section). This kind of association is described through a @JoinColumn
If you absolutely want it to be unidirectional, you'll need a join table (not just a main table and a collection table), and follow the instructions in 2.2.5.3.2.3 farther down in the document.