[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6541) ColumnValues.applyColumnValues tests presence of uniqueValue but reads nameValue
Erik Bertelsen (JIRA)
noreply at atlassian.com
Wed Aug 3 08:21:02 EDT 2011
ColumnValues.applyColumnValues tests presence of uniqueValue but reads nameValue
--------------------------------------------------------------------------------
Key: HHH-6541
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6541
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 4.0.0.Beta4
Environment: 4.0.0.Beta4, postgresql 9
Reporter: Erik Bertelsen
In https://github.com/hibernate/hibernate-core/blob/master/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/attribute/ColumnValues.java in the method applyColumnValues, the following lines are present:
AnnotationValue nameValue = columnAnnotation.value( "name" );
if ( nameValue != null ) {
this.name = nameValue.asString();
}
AnnotationValue uniqueValue = columnAnnotation.value( "unique" );
if ( uniqueValue != null ) {
this.unique = nameValue.asBoolean();
}
Note that this.unique is set from nameValue.asBoolean instead of the intended uniqueValue.asBoolean. This causes an IlleArgumentException (unless nameValue happens to be a valid boolean value). Only uniqueValue seems to be affected, the remaining properties look ok.
Suggested fix:
replace 'this.unique = nameValue.asBoolean();' by 'this.unique = uniqueValue.asBoolean();'
Consequence of this bug: It is not possible to annotate a property of an entity class by:
@Column(name = "someName", unique = true)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list