Note that there are some explanatory texts on larger screens.

plurals
  1. POORMLite error no databasefield annotations exists
    primarykey
    data
    text
    <p>I have this error when I run my Android application:</p> <blockquote> <p>No fields have a DatabaseField annotation in class [[Lmodel.Vak;</p> </blockquote> <p>My class Vak has annotations, so I really don't understand why it still giving me this error.</p> <pre><code>package model; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; @DatabaseTable(tableName = "vak") public class Vak { @DatabaseField(generatedId = true, columnName = "vakID", id=true) Long id; @DatabaseField int rij; @DatabaseField int kolom; ... } </code></pre> <p>I have a file called Databasehelper.java in which extends OrmLiteSqLiteOpenHelper and the file looks like this:</p> <pre><code>public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // name of the database file for your application -- change to something // appropriate for your app private static final String DATABASE_NAME = "project56.db"; // any time you make changes to your database objects, you may have to // increase the database version private static final int DATABASE_VERSION = 1; private DatabaseType databaseType = new SqliteAndroidDatabaseType(); // the DAO object we use to access the tables private Dao&lt;Vleugel, Long&gt; vleugelDao = null; private Dao&lt;Verdieping, Long&gt; verdiepingDao = null; private Dao&lt;NavigatiePunt, Long&gt; navigatiePuntDao = null; private Dao&lt;Lokaal, Long&gt; lokaalDao = null; private Dao&lt;Raster, Long&gt; rasterDao = null; private Dao&lt;Vak, Long&gt; vakDao = null; private Dao&lt;Graaf, Long&gt; graafDao = null; private Dao&lt;Vertex, Long&gt; vertexDao = null; private Dao&lt;Edge, Long&gt; edgeDao = null; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } /** * This is called when the database is first created. Usually you should * call createTable statements here to create the tables that will store * your data. */ @Override public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { try { Log.i(DatabaseHelper.class.getName(), "onCreate"); TableUtils.createTable(connectionSource, Vleugel.class); TableUtils.createTable(connectionSource, Verdieping.class); TableUtils.createTable(connectionSource, NavigatiePunt.class); TableUtils.createTable(connectionSource, Lokaal.class); TableUtils.createTable(connectionSource, Raster.class); TableUtils.createTable(connectionSource, Vak.class); TableUtils.createTable(connectionSource, Graaf.class); TableUtils.createTable(connectionSource, Vertex.class); TableUtils.createTable(connectionSource, Edge.class); } catch (SQLException e) { Log.e(DatabaseHelper.class.getName(), "Can't create database", e); throw new RuntimeException(e); } } /** * This is called when your application is upgraded and it has a higher * version number. This allows you to adjust the various data to match the * new version number. */ @Override public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) { try { Log.i(DatabaseHelper.class.getName(), "onUpgrade"); TableUtils.dropTable(connectionSource, Vleugel.class, true); TableUtils.dropTable(connectionSource, Verdieping.class, true); TableUtils.dropTable(connectionSource, NavigatiePunt.class, true); TableUtils.dropTable(connectionSource, Lokaal.class, true); TableUtils.dropTable(connectionSource, Raster.class, true); TableUtils.dropTable(connectionSource, Vak.class, true); TableUtils.dropTable(connectionSource, Graaf.class, true); TableUtils.dropTable(connectionSource, Vertex.class, true); TableUtils.dropTable(connectionSource, Edge.class, true); // after we drop the old databases, we create the new ones onCreate(db, connectionSource); } catch (SQLException e) { Log.e(DatabaseHelper.class.getName(), "Can't drop databases", e); throw new RuntimeException(e); } } /** * Returns the Database Access Object (DAO) for the classes It will create * it or just give the cached value. */ public Dao&lt;Vleugel, Long&gt; getVleugelDao() throws SQLException { if (vleugelDao == null) { vleugelDao = getDao(Vleugel.class); } return vleugelDao; } public Dao&lt;Verdieping, Long&gt; getVerdiepingDao() throws SQLException { if (verdiepingDao == null) { verdiepingDao = getDao(Verdieping.class); } return verdiepingDao; } public Dao&lt;NavigatiePunt, Long&gt; getNavigatiePuntDao() throws SQLException { if (navigatiePuntDao == null) { navigatiePuntDao = getDao(NavigatiePunt.class); } return navigatiePuntDao; } public Dao&lt;Lokaal, Long&gt; getLokaalDao() throws SQLException { if (lokaalDao == null) { lokaalDao = getDao(Lokaal.class); } return lokaalDao; } public Dao&lt;Raster, Long&gt; getRasterDao() throws SQLException { if (rasterDao == null) { rasterDao = getDao(Raster.class); } return rasterDao; } public Dao&lt;Vak, Long&gt; getVakDao() throws SQLException { if (vakDao == null) { vakDao = getDao(Vak.class); } return vakDao; } public Dao&lt;Graaf, Long&gt; getGraafDao() throws SQLException { if (graafDao == null) { graafDao = getDao(Graaf.class); } return graafDao; } public Dao&lt;Vertex, Long&gt; getVertexDao() throws SQLException { if (vertexDao == null) { vertexDao = getDao(Vertex.class); } return vertexDao; } public Dao&lt;Edge, Long&gt; getEdgeDao() throws SQLException { if (edgeDao == null) { edgeDao = getDao(Edge.class); } return edgeDao; } /** * Close the database connections and clear any cached DAOs. */ @Override public void close() { super.close(); vleugelDao = null; verdiepingDao = null; navigatiePuntDao = null; lokaalDao = null; rasterDao = null; vakDao = null; graafDao = null; vertexDao = null; edgeDao = null; } } </code></pre> <p>I also have a file Controller which extends OrmLiteBaseActivity:</p> <pre><code>public class Controller extends OrmLiteBaseActivity&lt;DatabaseHelper&gt; { Dao&lt;Vleugel, Long&gt; vleugelDao; Dao&lt;Verdieping, Long&gt; verdiepingDao; Dao&lt;NavigatiePunt, Long&gt; navigatiePuntDao; Dao&lt;Lokaal, Long&gt; lokaalDao; Dao&lt;Raster, Long&gt; rasterDao; Dao&lt;Graaf, Long&gt; graafDao; Dao&lt;Vertex, Long&gt; vertexDao; Dao&lt;Edge, Long&gt; edgeDao; Dao&lt;Vak, Long&gt; vakDao; // Databasehelper is benodigd voor ORMLite static { OpenHelperManager.setOpenHelperFactory(new SqliteOpenHelperFactory() { public OrmLiteSqliteOpenHelper getHelper(Context context) { return new DatabaseHelper(context); } }); } public Controller() throws SQLException { /** initialiseren van dao */ vleugelDao = getHelper().getVleugelDao(); verdiepingDao = getHelper().getVerdiepingDao(); navigatiePuntDao = getHelper().getNavigatiePuntDao(); lokaalDao = getHelper().getLokaalDao(); rasterDao = getHelper().getRasterDao(); graafDao = getHelper().getGraafDao(); vertexDao = getHelper().getVertexDao(); edgeDao = getHelper().getEdgeDao(); vakDao = getHelper().getVakDao(); } /** * Haalt vleugel idNaam op uit dao object bijv. K1 * * @return Vleugel * @throws java.sql.SQLException */ public Vleugel getVleugel(String vleugelIDNaam) throws java.sql.SQLException { // select * from vleugel where idNaam='{vleugelIDNaam}' QueryBuilder&lt;Vleugel, Long&gt; qb = vleugelDao.queryBuilder(); Where where = qb.where(); // the name field must be equal to "foo" where.eq("idNaam", vleugelIDNaam); PreparedQuery&lt;Vleugel&gt; preparedQuery = qb.prepare(); List&lt;Vleugel&gt; vleugelList = vleugelDao.query(preparedQuery); Log.v("Getvleugel", vleugelList.size() + ""); if (vleugelList.size() == 1) { return vleugelList.get(0); } return null; } public Verdieping getVerdieping(int nummer) throws java.sql.SQLException { // TODO: Met querybuilder query naar db om verdieping te pakken return null; } /** * Haalt navigatiepunt op * * @param naam * @return * @throws java.sql.SQLException */ public NavigatiePunt getNavigatiePunt(String naam) throws java.sql.SQLException { // select * from navigatiepunt where naam='{naam}' QueryBuilder&lt;NavigatiePunt, Long&gt; qb = navigatiePuntDao.queryBuilder(); Where where = qb.where(); where.eq("naam", naam); PreparedQuery&lt;NavigatiePunt&gt; preparedQuery = qb.prepare(); List&lt;NavigatiePunt&gt; navigatieList = navigatiePuntDao .query(preparedQuery); Log.v("GetLokaal", navigatieList.size() + ""); if (navigatieList.size() == 1) { return navigatieList.get(0); } return null; } /** * Get lokaal object op basis van lokaalcode * * @param lokaalcode * @return * @throws java.sql.SQLException */ public Lokaal getLokaal(String lokaalcode) throws java.sql.SQLException { // select * from lokaal where lokaalcode='{lokaalcode}' QueryBuilder&lt;Lokaal, Long&gt; qb = lokaalDao.queryBuilder(); Where where = qb.where(); where.eq("lokaalcode", lokaalcode); PreparedQuery&lt;Lokaal&gt; preparedQuery = qb.prepare(); List&lt;Lokaal&gt; lokaalList = lokaalDao.query(preparedQuery); Log.v("GetLokaal", lokaalList.size() + ""); if (lokaalList.size() == 1) { return lokaalList.get(0); } return null; } } </code></pre> <p>So do you have any advice on this, what should I check?</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