hello everyone,
I am learning hibernate annotations and I am stuck up with very first thing: how to forbid to remove object which was mapped using @OneToMany annotation, if it has related entities
Code:
[b]Somewhere:[/b]
.....
@OneToMany(fetch=FetchType.LAZY,cascade = { CascadeType.PERSIST },mappedBy="city")
@Fetch(FetchMode.SELECT)
public List<Shop> getShops() {
return shops;
}
....
[b]Related model:[/b]
@Entity
@Table(name = "T_SHOP")
public class Shop {
private City city;
...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CITY", nullable = false)
public City getCity() {
return city;
}
...
}
Is there somebody using an annottations, which can be solution for my problem? Thanks