persistence@glassfish.java.net

_at_Column Annotation related to length()

From: Pramod Gopinath <Pramod.Gopinath_at_Sun.COM>
Date: Wed, 25 Jan 2006 18:04:41 -0800

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