Skip to content

Commit 93da3a3

Browse files
author
zhangyinhao
committed
添加hibernate5.0.12版本支持
1 parent 865c6f6 commit 93da3a3

16 files changed

+113
-106
lines changed

pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.googlecode</groupId>
44
<artifactId>hibernate5-memcached</artifactId>
5-
<version>1.7-5.2.7-SNAPSHOT</version>
6-
<name>hibernate5-memcached</name>
5+
<version>1.7-5.0.12-SNAPSHOT</version>
6+
<name>hibernate5-memcached-1.7-5.0.12</name>
77
<description>A library for using Memcached as a second level distributed cache in Hibernate.</description>
88
<url>http://code.google.com/p/hibernate-memcached/</url>
99
<packaging>jar</packaging>
@@ -137,11 +137,12 @@
137137
<groupId>org.slf4j</groupId>
138138
<artifactId>slf4j-api</artifactId>
139139
<version>1.5.6</version>
140+
<scope>provided</scope>
140141
</dependency>
141142
<dependency>
142143
<groupId>org.hibernate</groupId>
143144
<artifactId>hibernate-core</artifactId>
144-
<version>5.2.7.Final</version>
145+
<version>5.0.12.Final</version>
145146
<scope>provided</scope>
146147
</dependency>
147148

src/main/java/com/googlecode/hibernate/memcached/region/MemcachedQueryResultsRegion.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
package com.googlecode.hibernate.memcached.region;
1717

1818
import com.googlecode.hibernate.memcached.MemcachedCache;
19+
1920
import org.hibernate.cache.CacheException;
2021
import org.hibernate.cache.spi.QueryResultsRegion;
21-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
22+
import org.hibernate.engine.spi.SessionImplementor;
2223
import org.slf4j.Logger;
2324
import org.slf4j.LoggerFactory;
2425

@@ -31,12 +32,12 @@ public MemcachedQueryResultsRegion(MemcachedCache cache) {
3132
}
3233

3334
@Override
34-
public Object get(SharedSessionContractImplementor session, Object key) throws CacheException {
35+
public Object get(SessionImplementor session, Object key) throws CacheException {
3536
return cache.get(key);
3637
}
3738

3839
@Override
39-
public void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
40+
public void put(SessionImplementor session, Object key, Object value) throws CacheException {
4041
cache.put(key, value);
4142
}
4243

@@ -48,4 +49,5 @@ public void evictAll() throws CacheException {
4849
cache.clear();
4950
}
5051

52+
5153
}

src/main/java/com/googlecode/hibernate/memcached/region/MemcachedTimestampsRegion.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
package com.googlecode.hibernate.memcached.region;
1717

1818
import com.googlecode.hibernate.memcached.MemcachedCache;
19+
1920
import org.hibernate.cache.CacheException;
2021
import org.hibernate.cache.spi.TimestampsRegion;
21-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
22+
import org.hibernate.engine.spi.SessionImplementor;
2223
import org.slf4j.Logger;
2324
import org.slf4j.LoggerFactory;
2425

@@ -31,12 +32,12 @@ public MemcachedTimestampsRegion(MemcachedCache cache) {
3132
}
3233

3334
@Override
34-
public Object get(SharedSessionContractImplementor session, Object key) throws CacheException {
35+
public Object get(SessionImplementor session, Object key) throws CacheException {
3536
return cache.get(key);
3637
}
3738

3839
@Override
39-
public void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
40+
public void put(SessionImplementor session, Object key, Object value) throws CacheException {
4041
cache.put(key, value);
4142
}
4243

src/main/java/com/googlecode/hibernate/memcached/strategy/AbstractMemcachedAccessStrategy.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
package com.googlecode.hibernate.memcached.strategy;
1616
import com.googlecode.hibernate.memcached.region.AbstractMemcachedRegion;
1717
import com.googlecode.hibernate.memcached.MemcachedCache;
18+
1819
import org.hibernate.boot.spi.SessionFactoryOptions;
1920
import org.hibernate.cache.CacheException;
2021
import org.hibernate.cache.spi.access.SoftLock;
21-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
22+
import org.hibernate.engine.spi.SessionImplementor;
2223

2324
public abstract class AbstractMemcachedAccessStrategy<T extends AbstractMemcachedRegion> {
2425

@@ -46,15 +47,15 @@ protected SessionFactoryOptions settings() {
4647
* This method is a placeholder for method signatures supplied by interfaces pulled in further down the class
4748
* hierarchy.
4849
*/
49-
public final boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version) throws CacheException {
50+
public final boolean putFromLoad(SessionImplementor session, Object key, Object value, long txTimestamp, Object version) throws CacheException {
5051
return putFromLoad(session, key, value, txTimestamp, version, settings.isMinimalPutsEnabled());
5152
}
5253

5354
/**
5455
* This method is a placeholder for method signatures supplied by interfaces pulled in further down the class
5556
* hierarchy.
5657
*/
57-
public abstract boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
58+
public abstract boolean putFromLoad(SessionImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
5859
throws CacheException;
5960

6061
/**
@@ -79,7 +80,7 @@ public void unlockRegion(SoftLock lock) throws CacheException {
7980
/**
8081
* A no-op since this is an asynchronous cache access strategy.
8182
*/
82-
public void remove(SharedSessionContractImplementor session, Object key) throws CacheException {
83+
public void remove(SessionImplementor session, Object key) throws CacheException {
8384
}
8485

8586
/**

src/main/java/com/googlecode/hibernate/memcached/strategy/AbstractReadWriteMemcachedAccessStrategy.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
package com.googlecode.hibernate.memcached.strategy;
1717

1818
import com.googlecode.hibernate.memcached.region.AbstractMemcachedRegion;
19+
1920
import org.hibernate.boot.spi.SessionFactoryOptions;
2021
import org.hibernate.cache.CacheException;
2122
import org.hibernate.cache.spi.CacheDataDescription;
2223
import org.hibernate.cache.spi.access.SoftLock;
23-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
24+
import org.hibernate.engine.spi.SessionImplementor;
2425
import org.slf4j.Logger;
2526
import org.slf4j.LoggerFactory;
2627

@@ -50,7 +51,7 @@ public AbstractReadWriteMemcachedAccessStrategy(T region, SessionFactoryOptions
5051
* Returns <code>null</code> if the item is not readable. Locked items are not readable, nor are items created
5152
* afterQuery the start of this transaction.
5253
*/
53-
public final Object get(SharedSessionContractImplementor session, Object key, long txTimestamp) throws CacheException {
54+
public final Object get(SessionImplementor session, Object key, long txTimestamp) throws CacheException {
5455
readLockIfNeeded(key);
5556
try {
5657
final Lockable item = (Lockable) region().get(key);
@@ -72,7 +73,7 @@ public final Object get(SharedSessionContractImplementor session, Object key, lo
7273
*/
7374
@Override
7475
public final boolean putFromLoad(
75-
SharedSessionContractImplementor session,
76+
SessionImplementor session,
7677
Object key,
7778
Object value,
7879
long txTimestamp,
@@ -98,7 +99,7 @@ public final boolean putFromLoad(
9899
/**
99100
* Soft-lock a cache item.
100101
*/
101-
public final SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException {
102+
public final SoftLock lockItem(SessionImplementor session, Object key, Object version) throws CacheException {
102103
region.getCache().lock(key);
103104
try {
104105
final Lockable item = (Lockable) region().get(key);
@@ -118,7 +119,7 @@ public final SoftLock lockItem(SharedSessionContractImplementor session, Object
118119
/**
119120
* Soft-unlock a cache item.
120121
*/
121-
public final void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException {
122+
public final void unlockItem(SessionImplementor session, Object key, SoftLock lock) throws CacheException {
122123
region.getCache().lock(key);
123124
try {
124125
final Lockable item = (Lockable) region().get(key);

src/main/java/com/googlecode/hibernate/memcached/strategy/NonStrictReadWriteMemcachedCollectionRegionAccessStrategy.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
package com.googlecode.hibernate.memcached.strategy;
1717

1818
import com.googlecode.hibernate.memcached.region.MemcachedCollectionRegion;
19+
1920
import org.hibernate.boot.spi.SessionFactoryOptions;
2021
import org.hibernate.cache.CacheException;
2122
import org.hibernate.cache.internal.DefaultCacheKeysFactory;
2223
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
2324
import org.hibernate.cache.spi.access.SoftLock;
2425
import org.hibernate.engine.spi.SessionFactoryImplementor;
25-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
26+
import org.hibernate.engine.spi.SessionImplementor;
2627
import org.hibernate.persister.collection.CollectionPersister;
2728

2829
public class NonStrictReadWriteMemcachedCollectionRegionAccessStrategy
@@ -34,12 +35,12 @@ public NonStrictReadWriteMemcachedCollectionRegionAccessStrategy(MemcachedCollec
3435
}
3536

3637
@Override
37-
public Object get(SharedSessionContractImplementor session, Object key, long txTimestamp) throws CacheException {
38+
public Object get(SessionImplementor session, Object key, long txTimestamp) throws CacheException {
3839
return null;
3940
}
4041

4142
@Override
42-
public final boolean putFromLoad(SharedSessionContractImplementor session,
43+
public final boolean putFromLoad(SessionImplementor session,
4344
Object key,
4445
Object value,
4546
long txTimestamp,
@@ -54,12 +55,12 @@ public final boolean putFromLoad(SharedSessionContractImplementor session,
5455
}
5556

5657
@Override
57-
public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException {
58+
public SoftLock lockItem(SessionImplementor session, Object key, Object version) throws CacheException {
5859
return null;
5960
}
6061

6162
@Override
62-
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException {
63+
public void unlockItem(SessionImplementor session, Object key, SoftLock lock) throws CacheException {
6364
region().remove(key);
6465
}
6566

src/main/java/com/googlecode/hibernate/memcached/strategy/NonStrictReadWriteMemcachedEntityRegionAccessStrategy.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
2323
import org.hibernate.cache.spi.access.SoftLock;
2424
import org.hibernate.engine.spi.SessionFactoryImplementor;
25-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
25+
import org.hibernate.engine.spi.SessionImplementor;
2626
import org.hibernate.persister.entity.EntityPersister;
2727

2828
/**
@@ -44,12 +44,12 @@ public NonStrictReadWriteMemcachedEntityRegionAccessStrategy(MemcachedEntityRegi
4444

4545

4646
@Override
47-
public Object get(SharedSessionContractImplementor session, Object key, long txTimestamp) throws CacheException {
47+
public Object get(SessionImplementor session, Object key, long txTimestamp) throws CacheException {
4848
return region().get(key);
4949
}
5050

5151
@Override
52-
public boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
52+
public boolean putFromLoad(SessionImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
5353
throws CacheException {
5454
if (minimalPutOverride && region.contains(key)) {
5555
return false;
@@ -65,7 +65,7 @@ public boolean putFromLoad(SharedSessionContractImplementor session, Object key,
6565
* Since this is a non-strict read/write strategy item locking is not used.
6666
*/
6767
@Override
68-
public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException {
68+
public SoftLock lockItem(SessionImplementor session, Object key, Object version) throws CacheException {
6969
return null;
7070
}
7171

@@ -75,7 +75,7 @@ public SoftLock lockItem(SharedSessionContractImplementor session, Object key, O
7575
* Since this is a non-strict read/write strategy item locking is not used.
7676
*/
7777
@Override
78-
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException {
78+
public void unlockItem(SessionImplementor session, Object key, SoftLock lock) throws CacheException {
7979
region().remove(key);
8080
}
8181

@@ -85,7 +85,7 @@ public void unlockItem(SharedSessionContractImplementor session, Object key, Sof
8585
* Returns <code>false</code> since this is an asynchronous cache access strategy.
8686
*/
8787
@Override
88-
public boolean insert(SharedSessionContractImplementor session, Object key, Object value, Object version) throws CacheException {
88+
public boolean insert(SessionImplementor session, Object key, Object value, Object version) throws CacheException {
8989
return false;
9090
}
9191

@@ -95,7 +95,7 @@ public boolean insert(SharedSessionContractImplementor session, Object key, Obje
9595
* Returns <code>false</code> since this is a non-strict read/write cache access strategy
9696
*/
9797
@Override
98-
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value, Object version) throws CacheException {
98+
public boolean afterInsert(SessionImplementor session, Object key, Object value, Object version) throws CacheException {
9999
return false;
100100
}
101101

@@ -105,21 +105,21 @@ public boolean afterInsert(SharedSessionContractImplementor session, Object key,
105105
* Removes the entry since this is a non-strict read/write cache strategy.
106106
*/
107107
@Override
108-
public boolean update(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion)
108+
public boolean update(SessionImplementor session, Object key, Object value, Object currentVersion, Object previousVersion)
109109
throws CacheException {
110110
remove(session, key);
111111
return false;
112112
}
113113

114114
@Override
115-
public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
115+
public boolean afterUpdate(SessionImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
116116
throws CacheException {
117117
unlockItem(session, key, lock);
118118
return false;
119119
}
120120

121121
@Override
122-
public void remove(SharedSessionContractImplementor session, Object key) throws CacheException {
122+
public void remove(SessionImplementor session, Object key) throws CacheException {
123123
region().remove(key);
124124
}
125125

src/main/java/com/googlecode/hibernate/memcached/strategy/NonStrictReadWriteMemcachedNaturalIdRegionAccessStrategy.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.hibernate.cache.spi.NaturalIdRegion;
2323
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
2424
import org.hibernate.cache.spi.access.SoftLock;
25-
import org.hibernate.engine.spi.SharedSessionContractImplementor;
25+
import org.hibernate.engine.spi.SessionImplementor;
2626
import org.hibernate.persister.entity.EntityPersister;
2727

2828

@@ -38,12 +38,12 @@ public NonStrictReadWriteMemcachedNaturalIdRegionAccessStrategy(MemcachedNatural
3838
}
3939

4040
@Override
41-
public Object get(SharedSessionContractImplementor session, Object key, long txTimestamp) throws CacheException {
41+
public Object get(SessionImplementor session, Object key, long txTimestamp) throws CacheException {
4242
return region().get(key);
4343
}
4444

4545
@Override
46-
public boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
46+
public boolean putFromLoad(SessionImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
4747
throws CacheException {
4848
if (minimalPutOverride && region.contains(key)) {
4949
return false;
@@ -59,7 +59,7 @@ public boolean putFromLoad(SharedSessionContractImplementor session, Object key,
5959
* Since this is a non-strict read/write strategy item locking is not used.
6060
*/
6161
@Override
62-
public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException {
62+
public SoftLock lockItem(SessionImplementor session, Object key, Object version) throws CacheException {
6363
return null;
6464
}
6565

@@ -69,7 +69,7 @@ public SoftLock lockItem(SharedSessionContractImplementor session, Object key, O
6969
* Since this is a non-strict read/write strategy item locking is not used.
7070
*/
7171
@Override
72-
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException {
72+
public void unlockItem(SessionImplementor session, Object key, SoftLock lock) throws CacheException {
7373
region().remove(key);
7474
}
7575

@@ -79,7 +79,7 @@ public void unlockItem(SharedSessionContractImplementor session, Object key, Sof
7979
* Returns <code>false</code> since this is an asynchronous cache access strategy.
8080
*/
8181
@Override
82-
public boolean insert(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
82+
public boolean insert(SessionImplementor session, Object key, Object value) throws CacheException {
8383
return false;
8484
}
8585

@@ -89,7 +89,7 @@ public boolean insert(SharedSessionContractImplementor session, Object key, Obje
8989
* Returns <code>false</code> since this is a non-strict read/write cache access strategy
9090
*/
9191
@Override
92-
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
92+
public boolean afterInsert(SessionImplementor session, Object key, Object value) throws CacheException {
9393
return false;
9494
}
9595

@@ -99,24 +99,24 @@ public boolean afterInsert(SharedSessionContractImplementor session, Object key,
9999
* Removes the entry since this is a non-strict read/write cache strategy.
100100
*/
101101
@Override
102-
public boolean update(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
102+
public boolean update(SessionImplementor session, Object key, Object value) throws CacheException {
103103
remove(session, key);
104104
return false;
105105
}
106106

107107
@Override
108-
public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock) throws CacheException {
108+
public boolean afterUpdate(SessionImplementor session, Object key, Object value, SoftLock lock) throws CacheException {
109109
unlockItem(session, key, lock);
110110
return false;
111111
}
112112

113113
@Override
114-
public void remove(SharedSessionContractImplementor session, Object key) throws CacheException {
114+
public void remove(SessionImplementor session, Object key) throws CacheException {
115115
region().remove(key);
116116
}
117117

118118
@Override
119-
public Object generateCacheKey(Object[] naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session) {
119+
public Object generateCacheKey(Object[] naturalIdValues, EntityPersister persister, SessionImplementor session) {
120120
return DefaultCacheKeysFactory.staticCreateNaturalIdKey(naturalIdValues, persister, session);
121121
}
122122

0 commit comments

Comments
 (0)