package com.example.dao;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* A JPA entity bean that represents one row in the system_settings table of
* the local database. Each row has a property key and value.
*
* @author Ryan de Laplante
* @since 4.0
*/
@Entity
@Table(name = "system_settings")
@NamedQueries({
@NamedQuery(name = "SystemSettingEntity.findByKey",
query = "SELECT s FROM SystemSettingEntity s " +
" WHERE s.key = :key"),
@NamedQuery(name = "SystemSettingEntity.findAllProperties",
query = "SELECT s FROM SystemSettingEntity s " +
"WHERE s.value = :value ORDER BY s.key")})
public class SystemSettingEntity implements Serializable {
@Id
@Column(name = "key", nullable = false)
private String key;
@Column(name = "value", nullable = false)
private String value;
/**
* Default constructor
*/
public SystemSettingEntity() {
}
/**
* Constructor that sets both key and value
*
* @param key the property's unique not-null name.
* @param value the property's value.
*/
public SystemSettingEntity(String key, String value) {
this.key = key;
this.value = value;
}
/**
* Returns the property's unique name. The name can be made up of upper and
* lower case letters, numbers, spaces and punctuation characters. The name
* will always be unique and can never be null or empty.
*
* @return the property's unique name
*/
public String getKey() {
return key;
}
/**
* Sets the property's unique name. The name can be made up of upper and
* lower case letters, numbers, spaces and punctuation characters. The name
* must always be unique and can never be null or empty.
*
* @param key the property's unique name
*/
public void setKey(String key) {
this.key = key;
}
/**
* Returns the value of the property this entity bean represents. The value
* can be empty, but never null. There is no restriction on characters or
* size of the value.
*
* @return the value of the property this entity bean represents.
*/
public String getValue() {
return value;
}
/**
* Sets the value of the property this entity bean represents. The value
* can be empty, but never null. There is no restriction on characters or
* size of the value.
*
* @param value the value of the property this entity bean represents.
*/
public void setValue(String value) {
this.value = value;
}
/**
* Returns the hashCode of the key String
, or 0 if the key is
* null.
*
* @return the hashCode of the key String
, or 0 if the key is
* null.
*/
@Override
public int hashCode() {
int hash = 0;
hash += (key != null ? key.hashCode() : 0);
return hash;
}
/**
* Returns true if the key is not null, the object passed in is an instance
* of SystemSettingEntity
, and both keys match. This method
* won't work if both key fields are not set.
*
* @param object an object the
* @return true if the key is not null, the object passed in is an instance
* of SystemSettingEntity
, and both keys match.
* Otherwise, it returns false.
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof SystemSettingEntity)) {
return false;
}
SystemSettingEntity other = (SystemSettingEntity) object;
if ((this.key == null && other.key != null) ||
(this.key != null && !this.key.equals(other.key))) {
return false;
}
return true;
}
/**
* Builds and returns a String
that follows this format:
*
* key=[0] value=[1]
*
* Where 0 is replaced with the key name, and 1 is replaced with the value.
*
* @return a String
that contains the key and value
*/
@Override
public String toString() {
return "key=[" + key + "] value=[" + value + "]";
}
}