realm

Realm taking too long to copy objects to RealmObject

淺唱寂寞╮ 提交于 2020-01-06 19:29:06
问题 I'm using realm to store a list of Products in my Andorid App. So, I receive a produtc's list with about 3k objects. And I'm trying to store them like this: @Override public void saveAll(List<ProductsDomain> domainProducts) throws InstantiationException, IllegalAccessException { Realm instance = getRealmInstance(); RealmList<ProdutcsRealm> realmProducts = new RealmList<ProdutcsRealm>(); try { ProdutcsRealm realmProduct = getClasseEntidadePersistencia().newInstance(); for (ProductsDomain

Delete model from Realm

女生的网名这么多〃 提交于 2020-01-06 19:28:36
问题 I am trying to remove a model from Realm. I appears there's a straightforward way to do it in Java with realm.getSchema().remove(className) It doesn't appear there is an option in Swift 3 other than to remove the model from the App and then migrate the data, or delete the entire Realm file. To clarify, when I open the Realm Browser I have three models Dog 2 Person 4 Test 0 and I want to remove just the Test model via code. There doesn't appear to be any way to remove it via the Browser either

Jackson cannot serialize an my realm object

淺唱寂寞╮ 提交于 2020-01-06 08:07:28
问题 I had a Route object and I saw that I can't serialize it. So I said I'll debug and try to serialize the objects from it, separately. This is my function: public JSONObject getRouteJson(Next_Step step) { JSONObject route = new JSONObject(); try { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); RouteNonRealm r = new RouteNonRealm(step.getRoute()); String string = mapper.writeValueAsString(r.getDuration()); route.put("duration", string

Save an object in NSUserDefaults and Realm

点点圈 提交于 2020-01-06 07:19:14
问题 Is it possible to save an object in both NSUserDefaults and Realm (Swift) ? I have found a problem in creating my Model since NSUserDefaults require the inheritance of NSObject and Realm requires the inheritance of Object . Doing so , raised this error Multiple inheritance from classes 'Object' and 'NSObject' 回答1: Using Swift4's Codable protocol, you can save a custom class to UserDefaults without having to conform to the old NSCoding protocol. class Team: Object, Codable { @objc dynamic var

Why can't I get the index of a filtered realm List?

泄露秘密 提交于 2020-01-06 06:56:28
问题 I'm trying to find the index of an item in a List<> object after the item has been appended to it, so that I can insert into a tableview. The tableview is sectioned with .filter s so I have to apply the filter before looking for the indexPath. However, the filter appears to break the indexOf functionality. I noticed that the function .map has the same effect. import UIKit import RealmSwift class Model: Object { @objc dynamic var title: String = "" let items = List<Model>() } class

Realm: Why on Devices/Emulators method RealmChangeListener.onChange() NOT call every times?

微笑、不失礼 提交于 2020-01-06 05:56:34
问题 Realm 3.5.0 Android application. My snippet: public class MainApp extends MultiDexApplication implements RealmChangeListener<RealmResults<PermissionOfferResponse>> { private void loginAndConfig() { String authUrl = "http://" + BuildConfig.OBJECT_SERVER_IP + ":" + BuildConfig.OBJECT_SERVER_PORT + "/auth"; SyncUser.Callback callback = new SyncUser.Callback() { @Override public void onSuccess(SyncUser user) { syncUser = user; createPermissionOfferAndSyncWithROS(); } @Override public void onError

how to avoid adding the same data in Realm database in many to many relationship?

可紊 提交于 2020-01-06 05:01:27
问题 I have wishlistVC that has collection view like the picture below: I have product realm model like this: class Product : Object { @objc dynamic var productID : String = "" @objc dynamic var name : String = "" @objc dynamic var unitPrice: Double = 0.0 @objc dynamic var quantity = 0 @objc dynamic var descriptionProduct : String = "" @objc dynamic var hasBeenAddedToWishList : Bool = false @objc dynamic var hasBeenAddedToCart : Bool = false @objc dynamic var isNewProduct : Bool = false var

Realm sample code from the docs gives 'io.realm.exceptions.RealmException: Dog is not part of the schema for this Realm'

醉酒当歌 提交于 2020-01-06 04:32:06
问题 I'm trying to adapt for Kotlin a very simple piece of Java Realm code straight from the docs: // Define your model class by extending RealmObject class Dog : RealmObject() { var name: String? = null var age: Int = 0 } class Person : RealmObject() { @PrimaryKey val id: Long = 0 val name: String? = null val dogs: RealmList<Dog>? = null // Declare one-to-many relationships } In onCreate : // Initialize Realm (just once per application) Realm.init(this); val config: RealmConfiguration =

Can I only call Realm.getInstance() once in Application?

痞子三分冷 提交于 2020-01-06 04:21:06
问题 I am toying with Realm and I always find that Realm.getInstance() is called during Activity create and instance closed in Activity destroy. May I know is there any side impact that keep only one instance create and open all the time until the application is closed? 回答1: There is no Application onDestroy. Realm does the necessary caching internally, so it should be safe to call Realm.getInstance()/close() as many times as you want. Trying to do your own caching will not make anything more

spring整合shiro框架

橙三吉。 提交于 2020-01-06 03:16:49
上一篇文章已经对shiro框架做了一定的介绍,这篇文章讲述使用spring整合shiro框架,实现用户认证已经权限控制 1.搭建环境 这里不在赘述spring环境的搭建,可以简单的搭建一个ssm框架,整合后进行简单的测试 1.1 添加依赖 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.3.2</version> </dependency> <!--shiro核心包--> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.3.2</version> </dependency> 1.2 web.xml配置 在web.xml中添加如下过滤器,注意filter-name的值是shiroFilter <!-- Shiro Security filter filter-name这个名字的值将来还会在spring中用到--> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter