ormlite

Joining classes in ORMLite for Android throws SQL exception: could not find a foreign class or vice versa

筅森魡賤 提交于 2020-01-04 13:35:11
问题 I'm trying to create a join query using QueryBuilder for two different classes, a Product class and a Coupon class, that references a Product attribute, the storeId . public class Coupon { @DatabaseField(columnName = TableColumns.PRODUCT, foreign = true, foreignColumnName = Product.TableColumns.STOREID) private Product product; } public class Product { @DatabaseField(columnName = TableColumns.ID, generatedId = true) private Integer id; @DatabaseField(columnName = TableColumns.STOREID, index =

ORM Lite throws error when creating tables containing multi level foreign key

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 05:51:27
问题 I'm getting this error on ORM Lite when creating table ActivityLog : 10-23 04:06:32.255: E/com.timelord.dao.DatabaseHelper(1487): Caused by: java.sql.SQLException: ORMLite can't store unknown class class com.timelord.pojo.Category for field 'category'. Serializable fields must specify dataType=DataType.SERIALIZABLE I suspected that this is caused by the multi level foreign key. As you can see from the POJO class below, ActivityLog has Activity, and Activity has Category. Activity and Category

how to generate a java class code from a sqlite database for ORMLite

做~自己de王妃 提交于 2020-01-03 14:19:46
问题 Given a sqlite database as input, I want to know how can i can generate an ORMLite java class that map with the associated database. Many thanks. 回答1: You could try Telosys Tools , an Eclipse plugin for code generation working from an existing database with customizable Velocity templates See: https://sites.google.com/site/telosystools/ A set of templates is available on GitHub for JPA : //github.com/telosys-tools-community/jpa-templates-TT206-v2 A Java class for JPA is very near to ORMLite

how to generate a java class code from a sqlite database for ORMLite

依然范特西╮ 提交于 2020-01-03 14:19:11
问题 Given a sqlite database as input, I want to know how can i can generate an ORMLite java class that map with the associated database. Many thanks. 回答1: You could try Telosys Tools , an Eclipse plugin for code generation working from an existing database with customizable Velocity templates See: https://sites.google.com/site/telosystools/ A set of templates is available on GitHub for JPA : //github.com/telosys-tools-community/jpa-templates-TT206-v2 A Java class for JPA is very near to ORMLite

ORMLite Issue with inserting tables from one database to another database on Android

北城以北 提交于 2020-01-02 05:30:33
问题 I'm downloading an SQLite database file from a server to the Android device of the user. After the download, I insert or replace some tables in the local database using the downloaded database. I use ORMLite 4.47 for this. First I attach the database files to the DatabaseConnection: DatabaseConnection con = null; con = conSrc.getReadWriteConnection(); con.executeStatement("attach database '" + localDatabase.getAbsolutePath() + "' as '" + localDb + "'", DatabaseConnection.DEFAULT_RESULT_FLAGS)

Case insensitive order by with ormlite and sqlite in android

微笑、不失礼 提交于 2020-01-02 03:51:05
问题 I want to order my data objects from an ORMLite DAO case insensitively. Currently I am using the following sqlite code to order my owner items case sensitively: ownerDao.queryBuilder().orderBy("Name", true).query(); I see here that sqlite supports case insensitive "order by" with the following raw SQL: SELECT * FROM owner ORDER BY Name COLLATE NOCASE Any easy way (easier than calling queryRaw() ) of adding the desired suffix? Could an alternative solution be to set the columnDefinition

ORMLite - Query foreign field

巧了我就是萌 提交于 2020-01-01 09:13:14
问题 Using ORMLite for Android, I need to build a query that returns orders by order id or by customer name. Please consider the following class declarations: @DatabaseTable(tableName = "order") public class Order { @DatabaseField(generatedId = true) private Long id; @DatabaseField(foreign = true, canBeNull = false, foreignAutoRefresh = true, columnName = "customer_id") private Customer customer; // default constructor, getters and setters... } @DatabaseTable(tableName = "customer") public class

ORM performance: is greenDAO faster than ORMLite?

强颜欢笑 提交于 2019-12-31 08:14:28
问题 I've been using ORMLite in my application and I was considering whether to move to greenDAO. Performance is a huge part of that decision, and greenDAO's Features page says: For the same given entity, greenDAO inserts and updates entities over 2 times faster, and loads entities 4.5 times faster for loading entities than ORMLite. ... (Figures and chart updated 10-23-2011) I thought ORMLite's config file generation step should remove the need for reflection at runtime. The ORMLite changlog

How do you use ORMLite with an abstract class?

百般思念 提交于 2019-12-30 12:52:51
问题 I have an base class Peripheral . Classes Sensor and Master are extensions of Peripheral . I need ORMlite to instantiate my Peripheral objects that were previously saved. Obviously any attempt to instantiate Peripheral reflectively will result in a ClassInstantiationException due to its abstractness. How can I have ORMlite load any Peripheral object since Peripheral is abstract? Here is the sample of what I am doing: @DatabaseTable(tableName="Peripheral") abstract class Peripheral {

Android ORMLite slow create object

被刻印的时光 ゝ 提交于 2019-12-30 09:55:15
问题 I am using ormLite to store data on device. I can not understand why but when I store about 100 objects some of them stores too long time, up to second. Here is the code from DatabaseManager: public class DatabaseManager public void addSomeObject(SomeObject object) { try { getHelper().getSomeObjectDao().create(object); } catch (SQLException e) { e.printStackTrace(); } } } public class DatabaseHelper extends OrmLiteSqliteOpenHelper public Dao<SomeObject, Integer> getSomeObjectDao() { if (null