Search code examples
oracle-databasejpaeclipselinkddl

DDL generation with EclipseLink on Oracle RDBMS: Generate varchar2 fields with character length semantics


I use eclipselink.ddl-generation.output-mode=database to generate the database schema. Can the generated SQL use character length semantics for generation of varchar2 fields? Enhance generated DDL of EclipseLink seems to related and an answer to this question would probably solve this.


Solution

  • There are two ways to change the SQL that is generated. The first would be to change the target database platform and is EclipseLink specific. This allows you to pick any database platform class, and you could override your database's platform to use what ever type definition you wanted, but this would be generic - ie all Strings would use a Varchar(255).

    Another way is to change it using JPA annotations. The @Column annotation allows specifying the length which may or may not be used for DDL, as well as defining the columnDefinition which is used for DDL. Something like @Column(name="..", columndefinition="Varchar2(255) NOT NULL")