columnDefinition = "TEXT" for all types of databases

What about something like this:

@Lob
private String someString;

I think it's more portable and should effectively generate TEXT or LONGTEXT data type.


If you use @LOB you'll have ORA-00932 exception with SQL containing DISTINCT (http://ora-00932.ora-code.com/)

I think that the solution depends on the bytes size of your string. If its < 4000 bytes, you can try using @Column(name = "...", length = 4000)

I suggest 4000 bytes for DB comptibility reason :

  • In oracle Oracle 8 to Oracle 11g, type VARCHAR2 max size is 4000 (A4 page format)
  • In DB2 10 for z/OS, type VARCHAR max size is 32704
  • In SQL Server 2012, type TEXT max size is 2,147,483,647 bytes

Tags:

Java

Jpa