Support @Where on @MappedSuperClass

Description

I am trying to annotate @Where(clause = "deleted = 'false'") in @MappedSuperclass. But Hibernate does not support.

@MappedSuperclass
@Where(clause = "deleted = 'false'")
public abstract class BaseEntity<ID extends Serializable> implements Serializable {

public static final String DELETED_COLUMN = "deleted";
public static final String ACTIVE_COLUMN = "active";

/** System generated Serial Version UID. */
private static final long serialVersionUID = 1L;

/** The id. */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id", nullable = false, updatable = false, columnDefinition = "BIGINT UNSIGNED")
protected ID id;

/** The active. */
@Column(nullable = false, columnDefinition = "BOOLEAN default '1'")
protected boolean active = true;

/** The deleted. */
@Column(nullable = false, columnDefinition = "BOOLEAN default '0'")
protected boolean deleted = false;

/**

  • Gets the id.
    *
    * @return the id
    */
    public ID getId() {
    return id;
    }

/**

  • Gets the active.
    *
    * @return the active
    */
    public boolean getActive() {
    return active;
    }

/**

  • Sets the active.
    *
    * @param active the new active
    */
    public void setActive(boolean active) {
    this.active = active;
    }

/**

  • Gets the deleted.
    *
    * @return the deleted
    */
    public Boolean getDeleted() {
    return deleted;
    }

/**

  • Sets the deleted.
    *
    * @param deleted the new deleted
    */
    public void setDeleted(boolean deleted) {
    this.deleted = deleted;
    }

/*

  • (non-Javadoc)
    *
    * @see java.lang.Object#hashCode()
    */
    @Override
    public int hashCode() {
    int hash = 0;
    hash += (this.getId() != null ? this.getId().hashCode() : 0);

return hash;
}

/*

  • (non-Javadoc)
    *
    * @see java.lang.Object#equals(java.lang.Object)
    */
    @Override
    public boolean equals(Object object) {
    if (this == object) return true;
    if (object == null) return false;
    if (getClass() != object.getClass()) return false;

BaseEntity<?> other = (BaseEntity<?>) object;
if (this.getId() != other.getId() && (this.getId() == null || !this.id.equals(other.id))) {
return false;
}
return true;
}

/*

  • (non-Javadoc)
    *
    * @see java.lang.Object#toString()
    */
    @Override
    public String toString() {
    return this.getClass().getName() + " [ID=" + id + "]";
    }
    }

Environment

Java 1.7, Eclipse 4.3, Spring 3.2.x Hibernate 4.2.8 Mysql 5.6

Assignee

Tomas Ludrovan

Reporter

nagaraj shan

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure