In case someone will need a solution for this.
1. Overwrite type mapping in dialects
Code:
class MyPostgreSQLDialect extends PostgreSQLDialect {
public MyPostgreSQLDialect() {
registerColumnType(Types.VARCHAR, Integer.MAX_VALUE, "character varying");
}
}
class MyHsqlDialect extends HSQLDialect {
public MyHsqlDialect() {
registerColumnType(Types.VARCHAR, Integer.MAX_VALUE, "longvarchar");
}
}
2. Specify corresponding length in mapping:
Code:
@Entity
class MyBean {
....
@Column(length = Integer.MAX_VALUE)
String unlimitedText;
}
3. In Hibernate configuration set property
hibernate.dialect=my.package.MyPostgreSQLDialect
4. In test Hibernate configuration set property
hibernate.dialect=my.package.MyHsqlDialect
After this Hibernate will use 'character varying' as column type for dev and production and 'longvarchar' for tests.