persistence@glassfish.java.net

RE: _at_Column Annotation related to length()

From: Mike Keith <michael.keith_at_oracle.com>
Date: Wed, 25 Jan 2006 22:34:25 -0500

Hi Pramod,

Most databases don't need, or even support specifying the length on BLOBs and CLOBs
so I wouldn't think it is really necessary to specify it. Does Derby?

-Mike
  -----Original Message-----
  From: Pramod Gopinath [mailto:Pramod.Gopinath_at_Sun.COM]
  Sent: Wednesday, January 25, 2006 9:05 PM
  To: michael.keith_at_oracle.com; Linda.Demichiel_at_Sun.COM
  Cc: persistence_at_glassfish.dev.java.net
  Subject: @Column Annotation related to length()


  Hi Mike/Linda

  I am trying to fix the RI code to ensure that it uses the @Column annotation specified by the user and ensure that the correct DDL gets generated for the field. I have some questions regarding the "int length()" in the @Column annotation.

  The spec states that "int length - Applies only if a string-valued column is used".

  Does this mean that this would apply only to a field that the user has defined as java.lang.String.
  Will this length() also apply to a Clob field ?

  Examples to further clarify my understanding:

  1.
  @Column(name="DESC")
  public String getDescription() {
    return description;
  }

  would ensure that we have a field created of the form
  DESC VARCHAR(255) (in DERBY)


  2.
  @Column(name="DESC", length=55)
  public String getDescription() {
    return description;
  }


  would ensure that we have a field created of the form
  DESC VARCHAR(55) (in DERBY)


  3.
  @Lob
  @Column(name="REPORT", length=1055)
  public String getReport() {
     return report;
  }

  do we create a field of the form
  REPORT CLOB(1055) ( in DERBY)
  OR
  REPORT CLOB(2147483647) (in Derby the max value for a CLOB is 2M )



  Further can the user define @Column:length for a blob type of field.


  Thanks
  Pramod