Code inspection reveals a copy/paste-bug in ColumnValues

Description

The code involved:
Class:org.hibernate.metamodel.source.annotations.attribute.ColumnValues
Method: applyColumnValues(AnnotationInstance)
Line 71 (according to the source attached to version 4.2.2.Final using ivy/maven):
AnnotationValue uniqueValue = columnAnnotation.value( "unique" );
if ( uniqueValue != null ) {
this.unique = nameValue.asBoolean();
}
Where nameValue should be uniqueValue.
This stops me from using the annotation:
@Column(name = "code", unique = true, nullable = false, length = 50)
The workaround is probably adding a unique-index using the @NaturalId, but this is non-standard.

(As this is only a copy/paste mistake I ticked the box 'Suitable for new contributors')

Environment

In a JBoss 7.1 type environment and with org.jboss.jandex.AnnotationValue.asBoolean in my class-path somehow. This might mean that when jandex is not there the alternative might be more forgiving towards the asBoolean which would then hide the mistake in org.hibernate.metamodel.source.annotations.attribute.ColumnValues

Activity

Show:
Gerke Ephorus
July 3, 2013, 8:32 AM

I now use the other way of making the field unique: using the @Table annotation combined with the @UniqueConstraint annotation:

which is more flexible (one can use multiple columns and one can specify a name of the index) and which is probably used more. But it's still a simple copy/paste mistake that would be nice to get rid of.

Emmanuel Bernard
July 3, 2013, 12:00 PM
Edited

I moved this bug to the ORM project as I suspect that's what you are using.

Gerke Ephorus
July 4, 2013, 12:15 PM

I would say this could also land in a 4.x.x bug-fix release, or am I wrong?

Brett Meyer
July 8, 2013, 12:18 AM

Using the new metamodel is not yet supported – the code in the master branch (4.3.x) is stale by several months. The metamodel branch will be 5.0.0.

Out of Date

Assignee

Brett Meyer

Reporter

Gerke Ephorus

Fix versions

Labels

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Major
Configure