Created
March 13, 2011 00:31
-
-
Save jacobheric/867742 to your computer and use it in GitHub Desktop.
Annotations based JPA entity persistence using Hibernate snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Recipe implements Serializable { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
private Long id; | |
private String name; | |
@Column(name = "brew_notes") | |
private String brewNotes; | |
private Timestamp start; | |
private Timestamp end; | |
@Column(name = "taste_notes") | |
private String tasteNotes; | |
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) | |
@JoinTable(name = "recipe_hops", | |
joinColumns = @JoinColumn(name = "recipe_id"), | |
inverseJoinColumns = @JoinColumn(name = "hop_id") | |
) | |
private Set<Hop> hops = new HashSet<Hop>(); | |
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) | |
@JoinTable(name = "recipe_malts", | |
joinColumns = @JoinColumn(name = "recipe_id"), | |
inverseJoinColumns = @JoinColumn(name = "malt_id") | |
) | |
private Set<Malt> malts = new HashSet<Malt>(); | |
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) | |
private Yeast yeast; | |
/** snip **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment