package basis.domain
import javax.persistence.Id
import javax.persistence.GeneratedValue
import javax.persistence.Column
import javax.persistence.Version
import javax.validation.constraints.NotNull
import javax.validation.constraints.Size
import javax.persistence.GenerationType
import org.apache.commons.lang3.builder.ToStringBuilder
import org.apache.commons.lang3.builder.ToStringStyle
import org.apache.commons.lang3.builder.HashCodeBuilder
import org.apache.commons.lang3.builder.EqualsBuilder
import javax.persistence.Entity
import javax.persistence.Table
import javax.persistence.NamedQueries
import javax.persistence.NamedQuery
import javax.xml.bind.annotation.XmlRootElement
/**
* @author Khaled.Noordin
*/
@Entity
@Table(name = "property")
// this section cause problems
@NamedQueries(
value = [
@NamedQuery(name = Property.FIND_BY_KEY, query = "select p from Property p where p.key = :key"),
@NamedQuery(name = Property.FIND_BY_VALUE, query = "select p from Property p where p.value = :value"),
@NamedQuery(name = Property.FIND_BY_VALUELIKE, query = "select p from Property p where p.value like :value"),
@NamedQuery(name = Property.FIND_BY_KEYLIKE, query = "select p from Property p where p.key like :key")
])
// what can I do to get it fixed
@XmlRootElement
class Property implements Serializable {
static final String FIND_BY_KEY = "Property.findByKey"
static final String FIND_BY_VALUE = "Property.findByValue"
static final String FIND_BY_KEYLIKE = "Property.findByKeyLike"
static final String FIND_BY_VALUELIKE = "Property.findByValueLike"
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "property_id")
Long id;
@Version
Integer version;
@Column(name = "property_key", unique = true)
@Size(min = 2, max = 128)
@NotNull
String key;
@Column(name = "property_value")
@Size(max = 1024, min = 1)
@NotNull
String value;
Property() {
id = null;
version = null;
key = null;
value = null;
}
Property(String key) {
this();
this.key = key;
}
Property(String key, String value) {
this(key);
this.value = value;
}
@Override
String toString() {
return ToStringBuilder.reflectionToString(
this,
ToStringStyle.SHORT_PREFIX_STYLE)
}
@Override
int hashCode() {
return HashCodeBuilder.reflectionHashCode(this, ["id", "version"])
}
@Override
boolean equals(Object object) {
return (!(object instanceof Property) || object == null) ? false : EqualsBuilder.reflectionEquals(this, object, ["id", "version"])
}
}