I have two tables table1, table2. Both have a one to one relation.
table2 contains foreign key of table1.
If I use
@OneToOne(cascade=CascadeType.ALL) or
@ManyToOne(fetch=FetchType.LAZY) for the method below. Then what will be the effect of it?
@Column( name = "table1_id" )
public Long getTable1Id() {
return this.table1Id;
}
If you use OneToOne than you need to define not id variable in class, but object of another class, like in these examples: http://docs.oracle.com/javaee/5/api/javax/persistence/OneToOne.html.
Lazy means that row from other table will not be fetched until accessed.
CascadeType.ALLmeans that all operations (like delete) will be propagated to associated object.