-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-6974 Class level naturalId cache and stats
Add class level @NaturalIdCache annotation to denote if second level natualId caching should be done Flush out stats model for naturalId cache related stats Add ehcache support classes for naturalId region
- Loading branch information
Showing
36 changed files
with
1,539 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
hibernate-core/src/main/java/org/hibernate/annotations/NaturalIdCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.annotations; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Add caching strategy for the NaturalId to Id of a root entity that has a natural id | ||
* | ||
* @author Eric Dalquist | ||
* @see NaturalId | ||
*/ | ||
@Target({TYPE, METHOD, FIELD}) | ||
@Retention(RUNTIME) | ||
public @interface NaturalIdCache { | ||
/** cache region name, defaults to full.entity.Name##NaturalId */ | ||
String region() default ""; | ||
} |
47 changes: 47 additions & 0 deletions
47
hibernate-core/src/main/java/org/hibernate/cache/spi/NaturalIdRegion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.cache.spi; | ||
|
||
import org.hibernate.cache.CacheException; | ||
import org.hibernate.cache.spi.access.AccessType; | ||
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy; | ||
|
||
/** | ||
* Defines the contract for a cache region which will specifically be used to | ||
* store naturalId data. | ||
* | ||
* @author Eric Dalquist | ||
*/ | ||
public interface NaturalIdRegion extends TransactionalDataRegion { | ||
|
||
/** | ||
* Build an access strategy for the requested access type. | ||
* | ||
* @param accessType The type of access strategy to build; never null. | ||
* @return The appropriate strategy contract for accessing this region | ||
* for the requested type of access. | ||
* @throws org.hibernate.cache.CacheException Usually indicates mis-configuration. | ||
*/ | ||
public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException; | ||
} |
50 changes: 50 additions & 0 deletions
50
...nate-core/src/main/java/org/hibernate/cache/spi/access/NaturalIdRegionAccessStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Inc. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.cache.spi.access; | ||
|
||
import org.hibernate.cache.spi.NaturalIdRegion; | ||
|
||
/** | ||
* Contract for managing transactional and concurrent access to cached naturalId | ||
* data. For cached naturalId data, all modification actions actually just | ||
* invalidate the entry(s). The call sequence here is: | ||
* {@link #lockItem} -> {@link #remove} -> {@link #unlockItem} | ||
* <p/> | ||
* There is another usage pattern that is used to invalidate entries | ||
* after performing "bulk" HQL/SQL operations: | ||
* {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion} | ||
* | ||
* @author Gavin King | ||
* @author Steve Ebersole | ||
* @author Eric Dalquist | ||
*/ | ||
public interface NaturalIdRegionAccessStrategy extends RegionAccessStrategy{ | ||
|
||
/** | ||
* Get the wrapped naturalId cache region | ||
* | ||
* @return The underlying region | ||
*/ | ||
public NaturalIdRegion getRegion(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.