added cache hints
This commit is contained in:
@ -2,30 +2,49 @@ package de.muehlencord.shared.account.entity;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
|
import javax.persistence.QueryHint;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author joern.muehlencord
|
* @author joern.muehlencord
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "config")
|
@Table(name = "config")
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@NamedQueries({
|
@Cacheable(true)
|
||||||
@NamedQuery(name = "ConfigEntity.findAll", query = "SELECT c FROM ConfigEntity c"),
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL, region = "Configuration")
|
||||||
@NamedQuery(name = "ConfigEntity.findByConfigKey", query = "SELECT c FROM ConfigEntity c WHERE c.configKey = :configKey"),
|
@NamedQueries({
|
||||||
@NamedQuery(name = "ConfigEntity.findByConfigValue", query = "SELECT c FROM ConfigEntity c WHERE c.configValue = :configValue")})
|
@NamedQuery(name = "ConfigEntity.findAll", query = "SELECT c FROM ConfigEntity c ORDER BY c.configKey",
|
||||||
|
hints = {
|
||||||
|
@QueryHint(name = "org.hibernate.cacheable", value = "true")
|
||||||
|
, @QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")})
|
||||||
|
, @NamedQuery(name = "ConfigEntity.findByConfigKey", query = "SELECT c FROM ConfigEntity c WHERE c.configKey = :configKey",
|
||||||
|
hints = {
|
||||||
|
@QueryHint(name = "org.hibernate.cacheable", value = "true")
|
||||||
|
, @QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")})
|
||||||
|
|
||||||
|
, @NamedQuery(name = "ConfigEntity.findByConfigValue", query = "SELECT c FROM ConfigEntity c WHERE c.configValue = :configValue",
|
||||||
|
hints = {
|
||||||
|
@QueryHint(name = "org.hibernate.cacheable", value = "true")
|
||||||
|
, @QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")})
|
||||||
|
})
|
||||||
|
|
||||||
public class ConfigEntity implements Serializable {
|
public class ConfigEntity implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = -2013982316933782223L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -42,8 +61,8 @@ public class ConfigEntity implements Serializable {
|
|||||||
public ConfigEntity(String configKey) {
|
public ConfigEntity(String configKey) {
|
||||||
this.configKey = configKey;
|
this.configKey = configKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigEntity (String configKey, String configValue) {
|
public ConfigEntity(String configKey, String configValue) {
|
||||||
this.configKey = configKey;
|
this.configKey = configKey;
|
||||||
this.configValue = configValue;
|
this.configValue = configValue;
|
||||||
}
|
}
|
||||||
@ -88,5 +107,5 @@ public class ConfigEntity implements Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "de.muehlencord.shared.account.entity.Config[ configKey=" + configKey + " ]";
|
return "de.muehlencord.shared.account.entity.Config[ configKey=" + configKey + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user