Reputation: 11891
Is it possible for Hibernate5 to map all String
s to TEXT
;
without annotating or mapping each field individually?
UPDATE
I've been doing some research on this and getting very close, but still no obvious path to a solution.
Clue #1
from https://docs.jboss.org/hibernate/orm/5.1/userguide/html_single/Hibernate_User_Guide.html
Tha link goes into https://docs.jboss.org/hibernate/orm/5.1/userguide/html_single/Hibernate_User_Guide.html#basic-custom-type, which is another rabbit-hole
Upvotes: 3
Views: 930
Reputation: 544
With hibernate you can ignore Annotation on each field if the field name and the column is the same. For example: Database: USER_NAME -> Field name: user_name;
To map VARCHAR type to String, you can create a custom Dialect. For example, If you use MySQL, you can create a class extend MySQLDialect and create mapping data type.
public class CustomMySQLDialect extends MySQLDialect {
public MySQLDialectDataType() {
registerHibernateType(Types.NVARCHAR, 255, "string");
registerHibernateType(Types.BIGINT, "long");
}
}
Upvotes: 1