JPA notes

Posted: April 9, 2013 in web

(usually where the foriegn key is)
@OneToOne
@JoinColumn(name = “SheetId”)
private QuoteSheet quoteSheet;

(usually where the reference table/entity)
@OneToOne(mappedBy = “quoteSheet”, cascade = CascadeType.ALL)
@JoinColumn(name = “Id”)
private QuoteEntity quoteEntity;

(usually where the foriegn key is)
@ManyToOne
@JoinColumn(name = “AdId”)
private Ad ad;

(usually where the reference table)
@OneToMany(mappedBy = “ad”, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List adDNC;

Calendar/Date type column shoud have an annotion of @Temporal(TemoralType.TIMESTAMP)

Primary key
@Id
@Column(name = “Id”, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s