Reputation: 6751
I have some long name classes which I store in the database using Hibernate.
I've noticed that hibernate creates the dtype column (for inheritance support) as character varying(31).
Since the class name is longer than 31 characters the insert fails.
What is the best way to resolve it?
Since I have lots of classes I prefer some global setting over adding annotation to each class.
Upvotes: 6
Views: 2140
Reputation: 15577
Alternative to JB Nizets answer is by specifying
@DiscriminatorColumn(length=100)
would provide a column that is long enough.
Upvotes: 16
Reputation: 692073
Use @DiscriminatorValue("some_short_name")
to all your subclasses. I don't think there is any other solution.
Upvotes: 4