Reputation: 12142
Hello i am using ORMLite 4.33.
I have an entity class that gives me an error when trying to destroyTable:
E/AndroidRuntime(6715): java.lang.IllegalArgumentException: Field class
java.lang.String for field FieldType:name=udm,class=Prodotti is not valid
for data persister com.j256.ormlite.field.types.EnumStringType@40a3a2e0
here is the class
@DatabaseTable(tableName = "Prodotti")
public class Prodotti extends BaseDaoEnabled{
....
@DatabaseField(dataType = DataType.ENUM_STRING,
columnDefinition="VARCHAR(100) DEFAULT NULL")
//also tried @DatabaseField(dataType = DataType.ENUM_STRING)
private String udm;
...
}
I runned DatabaseConfigUtil to update the ormlite_config.txt, right now i'm thinking the only solution is to change the type of the field to String
Upvotes: 0
Views: 1966
Reputation: 116908
ORMLite does not support database SQL enum columns which are only supported by a couple of database types. The ENUM_STRING
is supposed to persist an enum type. Something like:
@DatabaseField
private OurEnum udm;
...
public enum OurEnum {
RED, GREEN, BLUE;
}
By default, ORMLite will then persist the enum as it's string value (RED, GREEN, BLUE) in a VARCHAR
SQL field. If you have a String
field then you should just let it be persisted as a STRING
type. You can also use the DataType.ENUM_INTEGER
if you want to store its value instead but that is not recommended for backwards compatibility reasons.
If you edit your questions to better explain what you are trying to accomplish, I can edit my answer to provide more information.
Upvotes: 5