myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: AW: Bean Validation
Date Fri, 09 Sep 2011 10:23:55 GMT
Btw, slightly OT:

it is always a good idea to explicitly set the column size. There are a few arguments for
it:

Why waste space for e.g. an internal shortcut which is defined to be 20 chars wide in the
gui?

By default a database page is still only 8kB (or even 4kB sometimes) in most database setups.
In the Java/UTF world this means 4000 resp 2000 chars in 1 page!
If you have large objects, then you'll quickly exceed this size, thus slowing down your database.

Another bummer: In most databases, a combined unique index (by default) must not exceed 1kB
(500chars). Thus you cannot even combine 2 columns of that kind to an unique index ;)

LieGrue,
strub



----- Original Message -----
> From: Ing.Thomas Kernstock <t.kernstock@e-technologies.at>
> To: 'MyFaces Discussion' <users@myfaces.apache.org>; 'Mark Struberg' <struberg@yahoo.de>
> Cc: 
> Sent: Friday, September 9, 2011 11:22 AM
> Subject: AW: Bean Validation
> 
> hi mark,
> 
> thanx for the clarification !
> 
> best regards
> Thomas
> 
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de] 
> Gesendet: Freitag, 09. September 2011 10:42
> An: MyFaces Discussion
> Betreff: Re: Bean Validation
> 
> 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