Avner Levy
Avner Levy

Reputation: 6751

dtype column is too short to hold class name

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

Answers (2)

DataNucleus
DataNucleus

Reputation: 15577

Alternative to JB Nizets answer is by specifying

@DiscriminatorColumn(length=100)

would provide a column that is long enough.

Upvotes: 16

JB Nizet
JB Nizet

Reputation: 692073

Use @DiscriminatorValue("some_short_name") to all your subclasses. I don't think there is any other solution.

Upvotes: 4

Related Questions