0
エンティティ休止更新
@Table(name = "SERVICE")
public class Service implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The serviceId. */
@Id
@SequenceGenerator(name = "SERVICE_SEQ", sequenceName = "SERVICE_SEQ", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SERVICE_SEQ")
@Column(name = "SERVICE_ID", columnDefinition = "NUMBER(10)")
/** The description. */
@Column(name = "DESCRIPTION", columnDefinition = "VARCHAR(500)")
private String description;
@OneToMany(targetEntity = ServiceAddress.class, mappedBy = "service",
cascade = CascadeType.ALL, orphanRemoval = true)
private Set<ServiceAddress> serviceAddressSet;
}
@Entity
@Table(name = "ADDRESS")
public class ServiceAddress implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SERVICE_ADDRESS_SEQ")
@Column(unique = true, name = "SERVICE_ADDRESS_ID", columnDefinition = "NUMBER(10)")
private int serviceAddressId;
/** The service address. */
@Column(name = "ADDRESS", columnDefinition = "VARCHAR(200)" ,nullable = false)
private String address;
@ManyToOne
@JoinColumn(name = "SERVICE_ID",nullable = false)
private Service service;
/**
* Gets services.
*
* @return the services
*/
public Service getService() {
return service;
}
/**
* Sets services.
*
* @param services
* the services to set
*/
public void setService(Service service) {
this.service = service;
}
}
これらは私のエンティティクラスの2であり、私は特定のためのADDRESS
のテーブルに複数の行を削除したいですHibernateを使用してserviceId
を呼び出します。クエリserviceId
を使用できませんでした。なぜなら、ADDRESS
テーブルでは、サービスオブジェクトでマップしました。