Sure....
Here is the log statement:
2014-05-22 14:26:44,437 | WARN | Thread-128 | Schema |
b.log.SLF4JLogFactory$LogAdapter 103 | 156 - org.apache.openjpa - 2.3.0 | Existing column
"mime_type" on table "public.file_data" is incompatible with the same column in
the given schema definition. Existing column:
Full Name: file_data.mime_type
Type: varchar
Size: 255
Default: null
Not Null: false
Given column:
Full Name: file_data.mime_type
Type: varchar
Size: 30
Default: null
Not Null: false
And here is the column declaration in my model for FileData.mimeType:
@Column(name = "mime_type")
@Enumerated(EnumType.STRING)
private MimeType mimeType;
And from the schema creation script:
CREATE TABLE file_data (file_data_id BIGINT NOT NULL, date_created TIMESTAMP,
md5 VARCHAR(255), mime_type VARCHAR(30), name VARCHAR(255), path
VARCHAR(32672), PRIMARY KEY (file_data_id));
The longest value in the MimeType enum is 30 characters in length.
Observing some of the other warning messages, it seems that if the Enum
value length is less than 20, the expected column length is 20. So, 20
is the lower bounds.
Regards,
Jason
On 05/22/2014 05:01 PM, Kevin Sutter wrote:
Hi Jason,
I'm not aware of a change that went into 2.3.0 that would affect this type
of processing. I just searched the JIRAs as well and didn't find
anything... Can you post the exact warning message you are receiving?
Along with your Entity definition of the Enumerated type? And, extract the
schema definition from your database? I know we've had some issues with
sequence generators and Postgres, but I'm not aware of any issues with the
processing of enums.
Thanks, Kevin
On Thu, May 22, 2014 at 3:30 PM, Jason Reilly <jdr0...@renci.org> wrote:
With OpenJPA 2.2.2, the generated column length for an
@Enumerated(EnumType.STRING) is varchar(255) in Postgresql. With an
upgrade to OpenJPA 2.3.0, I think that the expected column length is the
length of the Enum's longest value....usually shorter than 255 characters.
I suspect this could problematic (at least annoying) if the database
schema was first created with OpenJPA 2.3.0 and the database column length
had to be adjusted every time I add a new Enum that is longer than the
previously longest Enum value.
On 05/22/2014 04:09 PM, Kevin Sutter wrote:
Well, if you don't have access or the means to update this varchar length,
then you probably have to ignore it... :-) This is a warning to indicate
a mismatch. I suppose you can ignore it, but then you have a chance of
truncated values. Are the enum values pre-defined like the column size?
Or, can you maybe abbreviate the enum values to make them fit the column
size? It's really up to you whether these warnings are safe to ignore or
not.
Kevin
On Thu, May 22, 2014 at 2:10 PM, Jason Reilly <jdr0...@renci.org> wrote:
Sorry....I am using OpenJPA 2.3.0
On 05/22/2014 03:09 PM, Jason Reilly wrote:
Hi all,
I am getting a warning that the column that an Enum is mapped to (as a
string) is incompatible with the column in the schema definition. Looks
like the expected column size is the length of the longest Enum value.
As
it is a warning and I don't easily have access to change the varchar
length, can this be safely ignored?
Thanks,
Jason