I have an application (spring / hibernate / ehcache 4.3.5 final) where the cache of most levels works for most objects.
But it seems to be broken down into the inheritance model TABLE_PER_CLASS, it seems that there is some confusion regarding the name of the entity in caches, the objects are obtained in this region as the name of the superclass, but when it goes to retrieve the object, it uses the name of the subclass.
So, I have 2 classes, one super and one under ...
@Entity
@Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
@Inheritance (strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name="group_link_entity")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE )
public abstract class GroupLinkEntity {
@TableGenerator(
name="sequenceGen",
table="database_sequence",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="ENTITY_ID",
allocationSize=1)
@Id
@GeneratedValue(strategy=GenerationType.TABLE, generator="sequenceGen")
@Column(name = "ENTITY_ID")
protected int id;
and
@Entity
@Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
@Table(name = "core_node")
public class Node extends GroupLinkEntity implements Serializable {
The region will, as expected, be named after the superclass. when the load is first launched, it places the object in the second level cache, which I see when working with statistics for the following code
Map cacheEntries = ((Session) em.getDelegate()).getSessionFactory().getStatistics().getSecondLevelCacheStatistics( element )
.getEntries();
if( cacheEntries.size() > 0 ){
System.out.println( " ... " + cacheEntries ) ;
}
prints out ...
- com.core.dao.GroupLinkEntity
... {1=CacheEntry(com.core.dao.Node)[........
So, I know that a Node object with PK 1 is there.
, , get NonStrictReadWriteEhcacheEntityRegionAccessStrategy, , ...
com.core.dao.Node#1
- , , , ,...
[com.core.dao.GroupLinkEntity#1]
, , - .
TwoPhaseLoad ...
final CacheKey cacheKey = session.generateCacheKey( id, persister.getIdentifierType(), persister.getRootEntityName() );
-, DefaultLoadEventListener...
final CacheKey ck = source.generateCacheKey(
event.getEntityId(),
persister.getIdentifierType(),
persister.getEntityName()
);
, - , , . , .
? ?