[hibernate-dev] Static constants in org.hibernate.engine.internal.Versioning
Steve Ebersole
steve at hibernate.org
Thu Jun 23 20:43:16 EDT 2011
On 06/23/2011 05:42 PM, Gail Badner wrote:
> I just ran into an issue where EntityBinding.getOptimisticLockMode() returns an ordinal from a org.hibernate.annotations.OptimisticLockType enum that is inconsistent with the static constants in org.hibernate.engine.internal.Versioning.
>
> Jira issue: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6362
>
> I'm not clear on what conventions there are for enums that are source-specific.
>
> My preference would be to:
>
> 1) Extract the static constants for version type from org.hibernate.engine.internal.Versioning into a new enum that is an SPI, org.hibernate.engine.spi.OptimisticLockMode.
>
> 2) Change EntityBinding.getOptimisticLockMode() and EntityBindingState.getOptimisticLockMode() to return org.hibernate.engine.spi.OptimisticLockMode.
>
> 3) Change sources to be responsible for converting from a source-specific value to org.hibernate.engine.spi.OptimisticLockMode.
Aside from the enum name, I think this is all goodness. These are
distinctly different from LockModes and we should avoid that confusion.
I tend to like to use the term "strategy" with pluggable interfaces,
but I think OptimisticLockingStrategy is definitely descriptive here.
Anyone else with better names?
> In the same vein, I see there is org.hibernate.metamodel.binding.CascadeType, which is not source-specific. In that class, there's a TODO to integrate it with org.hibernate.engine.spi.CascadeStyle.
>
> I also see that AttributeBindingState.getCascadeTypes() returns Set<CascadeType>.
>
> My preference would be to remove org.hibernate.metamodel.binding.CascadeType and to change AttributeBindingState.getCascadeTypes() and AbstractAttributeBinding.getCascadeTypes() to:
>
> org.hibernate.engine.spi.CascadeStyle getCascadeStyle();
I think this is fine. The comment is Hardy's though, so lets let him
respond to see if he had something else in mind.
--
Steve Ebersole <steve at hibernate.org>
http://hibernate.org
More information about the hibernate-dev
mailing list