Hi
I've a performance problem with a one to many relation and cascade setting.
The structure is
- one header
- many rows
the declararion is
Code:
@Entity
@Table(name="HEAD")
public class Head implements Serializable {
private Long id;
@Id
@Column(name="HEADID", length=11)
...
private List<Row> rows;
@OneToMany(mappedBy="despatchAdvice", cascade=CascadeType.ALL)
...
}
@Entity
@Table(name="ROW")
public class Row implements Serializable {
private Long id;
@Id
@Column(name="ROWID", length=11)
...
private Head ;
@ManyToOne
@JoinColumn(name="HEDADID", nullable=false)
@Fetch(FetchMode.JOIN)
...
}
when i execute the following code
Code:
session.update(head);
session.flush();
where head is an Head's instance, attached to N rows , and I only modified the head, hibernate do a multiple select for each head's row and then an head update.
if i cache the rows with
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
the N select are substituted with N update.
(I found this case on
http://forum.hibernate.org/viewtopic.php?t=982390&highlight= )
My questions are
- in the first case, is there any way to force hibernate to do a single select instead a multiple select?
- in the second case, is there any way to force hibernate to do only the necessary updates
Thanxs
Stefano