[hibernate] Effacer un type d'objet
Bonjour,
Voilà j'aimerais savoir avec la structure suivante comment je peux faire pour vérifier qu'un type de plats n'est pas utilisé lorsque je veux l'effacer.
Merci à quilo pour l'exemple et merci déjà à ceux qui pourront me répondre.
Citation:
Envoyé par quilo
Voici un exemple :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
public class Plats extends PojoAncestor{
private float price = 0;
private Set typeDePlats = new HashSet();
public Plats(){
}
public float getPrice(){
return price;
}
public void setPrice(float argPrice){
price = argPrice;
}
public void setTypeDePlats(Set argTypeDePlats){
typeDePlats = argTypeDePlats;
}
public Set getTypeDePlats(){
return typeDePlats;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
public class TypePlat extends PojoAncestor{
public TypePlat(){}
public boolean equals(TypePlat argTypePlat){
if (getId() != argTypePlat.getId()){
return false;
}
if (getName() != argTypePlat.getName()){
return false;
}
if (getDescription() != argTypePlat.getDescription()){
return false;
}
return true;
}
public int hashCode(){
return ((int)getId()) ^ (getName() != null ? getName().hashCode() : "".hashCode()) ^ (getDescription() != null ? getDescription().hashCode() : "".hashCode());
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<class name="be.quilovnic.hhadmin.management.pojo.Plats" table="plats">
<id name="id" column="id_plat" type="long">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="description"/>
<property name="price" type="float"/>
<set name="typeDePlats" table="typeplatcollection">
<key column="id_plat" />
<many-to-many column="id_typeplat" class="be.quilovnic.hhadmin.management.pojo.TypePlat" unique="true"/>
</set>
</class>
<class name="be.quilovnic.hhadmin.management.pojo.TypePlat" table="typeplat">
<id name="id" column="id_typeplat" type="long">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="description"/>
</class> |