Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to have an enum field in a class persisted with OrmLite?
    primarykey
    data
    text
    <p>I'm trying to persist the following class with <a href="http://ormlite.sourceforge.net/" rel="noreferrer">OrmLite</a>:</p> <pre><code>public class Field { @DatabaseField(id = true) public String name; @DatabaseField(canBeNull = false) public FieldType type; ... } </code></pre> <p>The <code>FieldType</code> is a <code>public enum</code>. The field, corresponding to the <code>type</code> is string in SQLite (is doesn't support enums). When I try to use it, I get the following exception:</p> <pre><code>INFO [main] (SingleConnectionDataSource.java:244) - Established shared JDBC Connection: org.sqlite.Conn@5224ee Exception in thread "main" org.springframework.beans.factory.BeanInitializationException: Initialization of DAO failed; nested exception is java.lang.IllegalArgumentException: Unknown field class class enums.FieldType for field FieldType:name=type,class=class orm.Field at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:51) at orm.FieldDAO.getInstance(FieldDAO.java:17) at orm.Field.fromString(Field.java:23) at orm.Field.main(Field.java:38) Caused by: java.lang.IllegalArgumentException: Unknown field class class enums.FieldType for field FieldType:name=type,class=class orm.Field at com.j256.ormlite.field.FieldType.&lt;init&gt;(FieldType.java:54) at com.j256.ormlite.field.FieldType.createFieldType(FieldType.java:381) at com.j256.ormlite.table.DatabaseTableConfig.fromClass(DatabaseTableConfig.java:82) at com.j256.ormlite.dao.BaseJdbcDao.initDao(BaseJdbcDao.java:116) at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:48) ... 3 more </code></pre> <p>So how do I tell OrmLite, values on the Java side are from an <code>enum</code>?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload