[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6998?page=c...
]
Steve Ebersole commented on HHH-6998:
-------------------------------------
Here is an initial swag...
{code:title=CustomEntityDirtinessStrategy.java|borderStyle=solid}
public interface CustomEntityDirtinessStrategy {
...
public void findDirty(DirtyCheckContext context, Object entity, Session session);
}
{code}
{code:title=DirtyCheckContext.java|borderStyle=solid}
public interface DirtyCheckContext {
public static interface AttributeContext {
public String getName();
public Type getType();
public Object getCurrentValue();
public Object getLoadedValue();
}
public static interface AttributeChecker {
public boolean isDirty(AttributeContext attributeContext);
}
public void doDirtyChecking(AttributeChecker attributeChecker);
}
{code}
Application code is already implementing {{CustomEntityDirtinessStrategy}}. The only new
requirement here is to implement {{AttributeChecker}}. As an example consider a case
where we hold a map of changed values on the entity itself:
{code:borderStyle=solid}
public class MyCustomEntityDirtinessStrategy implements CustomEntityDirtinessStrategy {
...
public void findDirty(DirtyCheckContext context, final Object entity, final Session
session) {
context.doDirtyChecking(
new AttributeChecker() {
public boolean isDirty(AttributeContext attributeContext) {
return ( (DirtyTrackingEntity) entity
).getChangedValueMap().containsKey( attributeContext.getName();
}
}
);
}
}
{code}
Expand CustomEntityDirtinessStrategy to define findDirty
--------------------------------------------------------
Key: HHH-6998
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6998
Project: Hibernate ORM
Issue Type: Improvement
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Fix For: 4.1.0
{{CustomEntityDirtinessStrategy}} allows applications to bypass dirty checking in cases
when they know an entity is not dirty.
In some of these application, they also carry along the initial ("loaded")
state. In those cases it might be more performant to allow them to tell us which fields
changed. If we go this route though I'd like to take it as an opportunity to explore
options for not exposing all these arrays to user code. So partially this issue will be a
discussion of possible approaches to that.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira