我正在使用Eclipse链接,我想删除所有带有子句的实体。但是当我这样做时,我得到了StackOverFlow错误。这是我用于删除的方法。有什么问题?
EntityManager em = getEntityManager();
try {
ACLEntry acle = new ACLEntry();
TypedQuery<ACLEntry> q = em.createQuery("DELETE from ACLEntry acle where acle.acl=:acl ", ACLEntry.class);
q.setParameter("acl", acl);
} catch (Exception ex) {
LOG.throwing("DAO", "removeAllACLEntries", ex);
// em.getTransaction().rollback();
}
finally {
em.close();
}
}
这是ACLEnrty实体:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.cisco.onepk_web.entity;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
/**
*
* @author abondar
*/
@Entity
@SequenceGenerator(name = "aclE_seq", sequenceName = "aclE_seq", initialValue = 1, allocationSize=1)
public class ACLEntry implements Serializable {
private static final long serialVersionUID = 1L;
@GeneratedValue(strategy = GenerationType.AUTO, generator="aclE_seq")
@Id
private Long id;
@ManyToOne(targetEntity = ACL.class)
private ACL acl;
private Integer seqNumber;
private String action;
private String protocol;
private String srcAddr;
private String dstAddr;
private String srcWcard;
private String dstWcard;
private Integer srcPort;
private Integer dstPort;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public ACL getAcl() {
return acl;
}
public void setAcl(ACL acl) {
this.acl = acl;
}
public Integer getSeqNumber() {
return seqNumber;
}
public void setSeqNumber(Integer seqNumber) {
this.seqNumber = seqNumber;
}
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public String getSrcAddr() {
return srcAddr;
}
public void setSrcAddr(String srcAddr) {
this.srcAddr = srcAddr;
}
public String getDstAddr() {
return dstAddr;
}
public void setDstAddr(String dstAddr) {
this.dstAddr = dstAddr;
}
public String getSrcWcard() {
return srcWcard;
}
public void setSrcWcard(String srcWcard) {
this.srcWcard = srcWcard;
}
public String getDstWcard() {
return dstWcard;
}
public void setDstWcard(String dstWcard) {
this.dstWcard = dstWcard;
}
public Integer getSrcPort() {
return srcPort;
}
public void setSrcPort(Integer srcPort) {
this.srcPort = srcPort;
}
public Integer getDstPort() {
return dstPort;
}
public void setDstPort(Integer dstPort) {
this.dstPort = dstPort;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + Objects.hashCode(this.id);
hash = 67 * hash + Objects.hashCode(this.acl);
hash = 67 * hash + Objects.hashCode(this.seqNumber);
hash = 67 * hash + Objects.hashCode(this.action);
hash = 67 * hash + Objects.hashCode(this.protocol);
hash = 67 * hash + Objects.hashCode(this.srcAddr);
hash = 67 * hash + Objects.hashCode(this.dstAddr);
hash = 67 * hash + Objects.hashCode(this.srcWcard);
hash = 67 * hash + Objects.hashCode(this.dstWcard);
hash = 67 * hash + Objects.hashCode(this.srcPort);
hash = 67 * hash + Objects.hashCode(this.dstPort);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ACLEntry other = (ACLEntry) obj;
if (!Objects.equals(this.id, other.id)) {
return false;
}
if (!Objects.equals(this.acl, other.acl)) {
return false;
}
if (!Objects.equals(this.seqNumber, other.seqNumber)) {
return false;
}
if (!Objects.equals(this.action, other.action)) {
return false;
}
if (!Objects.equals(this.protocol, other.protocol)) {
return false;
}
if (!Objects.equals(this.srcAddr, other.srcAddr)) {
return false;
}
if (!Objects.equals(this.dstAddr, other.dstAddr)) {
return false;
}
if (!Objects.equals(this.srcWcard, other.srcWcard)) {
return false;
}
if (!Objects.equals(this.dstWcard, other.dstWcard)) {
return false;
}
if (!Objects.equals(this.srcPort, other.srcPort)) {
return false;
}
if (!Objects.equals(this.dstPort, other.dstPort)) {
return false;
}
return true;
}
@Override
public String toString() {
return "ACLEntry{" + "id=" + id + ", acl=" + acl + ", seqNumber=" + seqNumber + ", action=" + action + ", protocol=" + protocol + ", srcAddr=" + srcAddr + ", dstAddr=" + dstAddr + ", srcWcard=" + srcWcard + ", dstWcard=" + dstWcard + ", srcPort=" + srcPort + ", dstPort=" + dstPort + '}';
}
}