myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: Bean Validation
Date Fri, 09 Sep 2011 08:41:44 GMT
Yup, Gerhard is right.

The reason is that JPA defines String fields as VARCHAR(255) by default.
Strings of larger size will be stored in CLOBs which have completely different indexing, etc.

LieGrue,
strub



----- Original Message -----
> From: Gerhard Petracek <gerhard.petracek@gmail.com>
> To: MyFaces Discussion <users@myfaces.apache.org>
> Cc: 
> Sent: Thursday, September 8, 2011 9:34 PM
> Subject: Re: Bean Validation
> 
> hi thomas,
> 
> length of @Column should help. e.g. @Column(length = 512)
> 
> regards,
> gerhard
> 
> http://www.irian.at
> 
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
> 
> Professional Support for Apache MyFaces
> 
> 
> 
> 2011/9/8 Ing.Thomas Kernstock <t.kernstock@e-technologies.at>
> 
>>  Hi Group !
>> 
>>  I have a weird problem with bean validation in JSF and hope someone can
>>  help
>>  me.
>> 
>>  I have a JEE6 project using JPA2, JSF2, MyFaces CODI 1.0 and MyFaces Extval
>>  2.0.5 (bean, core and property module).
>> 
>>  I have an entity with a field ->
>> 
>> 
>>  @Entity
>>  @Table(name="bewerbungen")
>>  public class Bewerbung extends BaseEntityVersioned implements Serializable
>>  {
>>  .....
>>         @Lob
>>         @Column(name="Bemerkung")
>>         private String bemerkung;
>>  .....
>>  }
>> 
>>  a Form with h:inputTextarea that writes directly to the entity ->
>> 
>>  <h:outputLabel for="bemerkung" 
> value="#{msgs.bewerben_bemerkungen}" />
>>  <h:inputTextarea id="bemerkung"
>>  value="#{applyForJobPage.bewerbung.bemerkung}" 
> rows="12" cols="75"
>>  label="#{msgs.bewerben_bemerkungen}"  />
>> 
>>  and a view bean->
>> 
>>  @Named
>>  @ViewAccessScoped
>>  public class ApplyForJobPage extends AbstractProfilePage{
>> 
>>         private Bewerbung bewerbung;
>> 
>>  ... getter and setter ...
>>  }
>> 
>> 
>>  There are no validations defined but when I copy a text longer than 255
>>  character into the text field I get a validation Error ! (=> 
> Anschreiben:
>>  Überprüfungsfehler: Wert ist größer als der zulässige Maximalwert 
> "255")
>> 
>>  I also tried to change the code to:
>> 
>>   <h:inputTextarea id="bemerkung"
>>  value="#{applyForJobPage.bewerbung.bemerkung}" 
> rows="12" cols="75"
>>  label="#{msgs.bewerben_bemerkungen}" >
>>  <f:validateLength maximum="512" />
>>  </h:inputTextarea>
>> 
>>  and
>> 
>>  @Lob
>>  @Size(max=512)
>>  @Column(name="Bemerkung")
>>  private String bemerkung;
>> 
>>  Both didn't work. The only thing that works would be to define a string 
> in
>>  the view bean and move this string into the entity later.
>> 
>>  I couldn't find any hints in the internet about a default length of 255
>>  characters.
>> 
>>  Any ideas ?
>> 
>>  best regards
>> 
>>  Thomas
>> 
>> 
>> 
>> 
>

Mime
View raw message