forked from Archives/Athou_commafeed
initial support for infinispan as 2nd level caching layer
This commit is contained in:
17
pom.xml
17
pom.xml
@@ -18,6 +18,7 @@
|
||||
<jpa.show_sql>false</jpa.show_sql>
|
||||
<jpa.datasource.name>java:openejb/Resource/My DataSource</jpa.datasource.name>
|
||||
<jpa.dialect>org.hibernate.dialect.HSQLDialect</jpa.dialect>
|
||||
<jpa.cache>false</jpa.cache>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -108,6 +109,16 @@
|
||||
<lib>org.hsqldb:hsqldb:SNAPSHOT</lib>
|
||||
<lib>mysql:mysql-connector-java:5.1.24</lib>
|
||||
<lib>postgresql:postgresql:9.1-901.jdbc4</lib>
|
||||
|
||||
<lib>org.infinispan:infinispan-core:5.1.4.FINAL</lib>
|
||||
<lib>org.hibernate:hibernate-infinispan:4.1.11.Final</lib>
|
||||
<lib>org.jgroups:jgroups:3.0.9.Final</lib>
|
||||
<lib>org.jboss.marshalling:jboss-marshalling-river:1.3.11.GA</lib>
|
||||
<lib>org.jboss.marshalling:jboss-marshalling:1.3.11.GA</lib>
|
||||
<lib>org.codehaus.woodstox:woodstox-core-asl:4.1.1</lib>
|
||||
<lib>org.codehaus.woodstox:stax2-api:3.1.1</lib>
|
||||
<lib>org.rhq.helpers:rhq-pluginAnnotations:3.0.4</lib>
|
||||
<lib>org.jboss.logmanager:jboss-logmanager:1.2.2.GA</lib>
|
||||
</libs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@@ -409,6 +420,12 @@
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>cache</id>
|
||||
<properties>
|
||||
<jpa.cache>true</jpa.cache>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>mysql</id>
|
||||
<properties>
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.commafeed.backend.model;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -12,11 +13,16 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDS")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class Feed extends AbstractModel {
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
@@ -10,11 +11,16 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDCATEGORIES")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class FeedCategory extends AbstractModel {
|
||||
|
||||
@Column(length = 128, nullable = false)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.commafeed.backend.model;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -16,11 +17,16 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.google.api.client.util.Sets;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRIES")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class FeedEntry extends AbstractModel {
|
||||
|
||||
@Column(length = 2048, nullable = false)
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRYCONTENTS")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class FeedEntryContent extends AbstractModel {
|
||||
|
||||
@Column(length = 2048)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
@@ -7,9 +8,14 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRYSTATUSES")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class FeedEntryStatus extends AbstractModel {
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -11,9 +12,14 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDSUBSCRIPTIONS")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class FeedSubscription extends AbstractModel {
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.commafeed.backend.model;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -12,11 +13,16 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERS")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class User extends AbstractModel {
|
||||
|
||||
@Column(length = 32, nullable = false, unique = true)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
@@ -9,9 +10,14 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERROLES")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class UserRole extends AbstractModel {
|
||||
|
||||
public static enum Role {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
@@ -10,9 +11,14 @@ import javax.persistence.Lob;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name = "USERSETTINGS")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class UserSettings extends AbstractModel {
|
||||
|
||||
public enum ReadingMode {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<persistence-unit name="primary" transaction-type="JTA">
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
<jta-data-source>${jpa.datasource.name}</jta-data-source>
|
||||
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
|
||||
<properties>
|
||||
|
||||
<property name="format_sql" value="true" />
|
||||
@@ -21,6 +22,28 @@
|
||||
<property name="hibernate.order_updates" value="true" />
|
||||
|
||||
<property name="hibernate.generate_statistics" value="true" />
|
||||
|
||||
<property name="hibernate.cache.use_second_level_cache"
|
||||
value="${jpa.cache}" />
|
||||
<property name="hibernate.cache.use_query_cache" value="false" />
|
||||
|
||||
<property name="hibernate.cache.region.factory_class"
|
||||
value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
|
||||
<property name="hibernate.cache.infinispan.statistics"
|
||||
value="true" />
|
||||
|
||||
<property name="hibernate.cache.infinispan.entity.eviction.strategy"
|
||||
value="LRU" />
|
||||
<property
|
||||
name="hibernate.cache.infinispan.entity.eviction.wake_up_interval"
|
||||
value="2000" />
|
||||
<property name="hibernate.cache.infinispan.entity.eviction.max_entries"
|
||||
value="100000" />
|
||||
<property name="hibernate.cache.infinispan.entity.expiration.lifespan"
|
||||
value="60000" />
|
||||
<property name="hibernate.cache.infinispan.entity.expiration.max_idle"
|
||||
value="30000" />
|
||||
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
Reference in New Issue
Block a user