ormlite

Create multiple tables for one class in ORMLite

妖精的绣舞 提交于 2019-12-05 05:23:57
I'm using ORMLite on Android and have the following question: Is it possible to create many tables based on a single Java class? The tables should only differ in their names, and the access to them should be by name. For example if I have a class: public class Order{ @DatabaseField public string Name; @DatabaseField public string Amount; } And I have a dynamic number of modules that can create orders. I want every module to have its own table, but all tables should have a similar schema. I know I can add a field in the Order class that indicates the source module name, and have all the orders

Ormlite Android bulk inserts

断了今生、忘了曾经 提交于 2019-12-05 03:58:46
can anyone explain why my inserts are taking so long in Ormlite? Doing 1,700 inserts in one sqlite transaction on the desktop takes less than a second. However, when using Ormlite for Android, it's taking about 70 seconds, and I can see each insert in the debugging messages. When I try and wrap the inserts into one transaction it goes at exactly the same speed. I understand that there is overhead both for Android and for Ormlite, however, I wouldn't expect it to be that great. My code is below: this.db = new DatabaseHelper(getApplicationContext()); dao = db.getAddressDao(); final

How to do multiple column unique-constraint in ormlite ( SQLite )

牧云@^-^@ 提交于 2019-12-05 02:44:44
I'm using ormlite for Android and I'm trying to get a multiple column unique-constraint. As of now i'm only able to get a unique constraint on indiviudal columns like this: CREATE TABLE `store_group_item` (`store_group_id` INTEGER NOT NULL UNIQUE , `store_item_id` INTEGER NOT NULL UNIQUE , `_id` INTEGER PRIMARY KEY AUTOINCREMENT ); and what I want is CREATE TABLE `store_group_item` (`store_group_id` INTEGER NOT NULL , `store_item_id` INTEGER NOT NULL , `_id` INTEGER PRIMARY KEY AUTOINCREMENT, UNIQUE( `store_group_id`, `store_item_id` ); In my model I've been using the following annotations for

Ormlite escape string method?

一笑奈何 提交于 2019-12-04 18:54:27
问题 Is there a native way of escaping strings for Ormlite for Android? For example, if I want to supply a string: ormlite's escape func, it needs to be supplied as ormlite\'s escape func. TestDao.queryForFirst(TestDao.queryBuilder().where().like("stats", stats) .prepare()) I tried using UpdateBuilder's escapeValue method, but it only makes the following change: 'ormlite's escape func'. It adds single quotes to beginning and end of the statement. Is there a native support for escaping strings to

exception while using jackson and ormlite annotations together in one object

你说的曾经没有我的故事 提交于 2019-12-04 15:17:45
I am using Jackson library to parse json into object and using ormlite to store same objects to the sqlite db. Here is my model classes: public class Site { private String uniqueId; private String name; private ForeignCollection<ContactDetails> items; @JsonProperty("contact_details") public void setContactDetails(ForeignCollection<ContactDetails> contact_details) { this.items = contact_details; } public List<ContactDetails> getContactDetails() { return new ArrayList<ContactDetails>(items); } public String getUniqueId() { return uniqueId; } @JsonProperty("unique_id") public void setUniqueId

Why is the DAO method so slow in ORMLite?

随声附和 提交于 2019-12-04 13:18:26
问题 I have a method that looks like this public Dao<ModelStore, Integer> getDaoStore() throws SQLException { return BaseDaoImpl.createDao(getConnectionSource(), ModelStore.class); } when i call getDaoStore it is quite a lengthy process. In my log's i can see that the GC runs after every call to this, so I'm guessing there's a lot going on with this call. Is there a way to speed this up? 回答1: A deep examination of Android-land has revealed that because of a gross Method.equals() method,

Having a list of strings represented in a database using ORMLite

让人想犯罪 __ 提交于 2019-12-04 13:02:30
First of I am new to ORMLite. I would like my model class to have a field which is a list of strings, that would eventually hold a list of tags for my model object. Which ORMLite annotations should I use? Firstly I don't want to have a table of all tags, and then use the @ForeignCollectionField . Also I thought of using the @DatabaseField(dataType=DataType.SERIALIZABLE) annotation, but it turns out that List<String> doesn't implement the Serializable interface. What are your suggestions? First of all, List doesn't implement Serializable but ArrayList certainly does as well as most of the

Problems saving Collection using ORMLite on Android

老子叫甜甜 提交于 2019-12-04 11:10:09
I have two class: public class Questionnaire { @DatabaseField(generatedId=true, useGetSet=true) private Long id; @DatabaseField private int type; @DatabaseField private String title; @DatabaseField private String description; @ForeignCollectionField(eager = true) private Collection<Question> questions; // Get and Set omitted and public class Question { @DatabaseField(generatedId=true, useGetSet=true) private Long id; @DatabaseField private int type; @DatabaseField private String description; @DatabaseField(foreign = true, foreignAutoRefresh= true) private Questionnaire questionario; //get and

Problems with ORMLite and lazy collections

心已入冬 提交于 2019-12-04 08:28:57
I am using ormlite in my android project. I have two classes @DatabaseTable(tableName = "usershows") public class UserShow { @DatabaseField(id = true) private Integer showId; @ForeignCollectionField(eager = false) private ForeignCollection<Episode> episodes; ... } @DatabaseTable(tableName = "episodes") public class Episode { @DatabaseField(id = true) private Integer episodeId; @DatabaseField(foreign = true) private UserShow show; ... } I am saving my UserShows objects like in example UserShow show = new UserShow(); userShowDao.create(show); for (Episode e: eps) { e.setShow(show); episodeDao

ORMLite - Query foreign field

£可爱£侵袭症+ 提交于 2019-12-04 05:04:45
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 Customer { @DatabaseField(generatedId = true) private Long id; @DatabaseField private String name; //