[
http://jira.jboss.com/jira/browse/JBSEAM-1530?page=comments#action_12389714 ]
Dan Allen commented on JBSEAM-1530:
-----------------------------------
The LengthValidator returns false if the property is not a String. On the other hand, a
char can only be length 1 or null. So it is a pointless validation in this case. I think
the right step is for seam-gen to not put this annotation.
I have submitted an issue and suggested change for the Hibernate Validator. After all,
java.lang.Character does satisfy @Length(max = 1). What is valid is valid. Stupid, but
valid. I rest my case.
http://opensource.atlassian.com/projects/hibernate/browse/HV-33
Either way, we don't need the @Length if the column type is char.
Seam-gen: @Length in char(1) property
-------------------------------------
Key: JBSEAM-1530
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1530
Project: JBoss Seam
Issue Type: Bug
Components: Tools
Affects Versions: 1.3.0.ALPHA
Reporter: Luiz Augusto Ruiz
Assigned To: Dan Allen
Fix For: 2.0.1.GA
Attachments: JBSEAM-1530-v1.txt
Seam-gen put a @Length Hibernate validator in char property. When a field of a table is
CHAR(1) Hibernate generates a char property and seam-gen put a @Length(size=1).
This can be fixed updating the template pojo/GetPropertyAnnotation.ftl:
<#include "Ejb3PropertyGetAnnotation.ftl"/>
<#if !property.optional>
@${pojo.importType("org.hibernate.validator.NotNull")}
</#if>
<#if property.columnSpan==1>
<#assign column = property.getColumnIterator().next()/>
<#if !c2h.isManyToOne(property) && !c2h.isTemporalValue(property) &&
column.length!=255 && column.length!=1>
@${pojo.importType("org.hibernate.validator.Length")}(max=${column.length?c})
</#if>
</#if>
" && column.length!=1" fix the bug.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira