Dear realm-Team,
I'm really impressed by Realm and I do like the way you're providing support and solutions on github, SO and gGroups! I like working with Realm - however there are three really big drawbacks for me:
1) No model-instantiation by = new ...
- I know you're on it. I can't wait for this! Do we have to wait for the "whole" JSON-Upgrade or will there be an earlier release providing this feature?
2) No model-passing across threads. That's hindering all the great benefits of EventBus and Android Priority Job Queue. But I read that it will be possible in the further versions and I'm looking forward on this.
3) The reason for this issue:
In my model class I'm allowed to have primitive fields as well as object fields of objects that extend RealmObject
.
But I'm not allowed to have a field type like RealmList<Integer>
or RealmList<String>
.
However it is possible to work around this by
RealmList<RealmString> names;
and
public class RealmString extends RealmObject {
private String name;
// getter & setter
It works but it's _really_ ugly and should be unnecessary in my opinion.
Is there any improvement planned regarding this?
Thanks again for your great work - I'm glad Realm helps me developing my app!
Related PRs:
I had bit of worries about the Realm design but after using it a lot i have seen it is done just right. My primary use of Realm is to pass data between threads (background processing and UI) and it works perfectly. It is so fast that even AsyncTasks are not needed anymore. Great work. Just few bugs left but easy to work around while waiting for the completion. I hope the next release comes out soon.
@an-k I think that your suggestion (RealmList<String>
etc.) is a good one. The complexity of implementing it is "less than impossible" but "greater than trivial". In particular the querying these lists of primitive types could be a bit tricky.
To make a long story short, I can give you a time frame in which it will be implemented.
@kneth Thanks for your reply! You can give a time frame? That's great, so when will that probably be?
@an-k Sorry for being unclear (I forgot a "not"); we don't have any time frame as we haven't decided if we wish to support it.
@kneth This issue is the major reason for not using it in production yet, I can't change my JSON input, so to use it, I would have to do some really ugly tricks.
And with issues #489 and now #682 rising, I think it should be considered worth supporting.
For my use cases, if it got serialized as a string in the database and back as List, without any type of in db querying (no need to limit, search, just retrieve all), would be perfect.
I think that should be added some kind of RealmPrimitive class or an @ElementCollection annotation like the JPA 2 has.
Can I ask what the current state and/or priority of this feature request is?
Or: What is the recommended workaround for now?
I agree that this is a worthwhile feature. +1.
Yes, please
+1
Would help solve issues like http://stackoverflow.com/questions/28733024/gson-deserialization-of-liststring-into-realmlistrealmstring
+1
+1
Not only primitive datatypes should be mentioned. Enums should be set in a list too.
+1 for the List of primitive and also +1 for the Enums.
I'm actually kinda stuck now as I have a JSON with a list of strings that needs to go to the DB, not quite sure yet how to deal with that.
+1
+1
+1
+1
+1
+1
A list of Strings is a very common use case for JSON responses. When you are given an array of Strings such as
"phoneNumbers":["000-000-0000", "111-111-1111"]
and you need to store it in the database, you need a list of Strings.
Implementing a workaround for every instance of a JSONArray of Strings would be bloated and ugly, unless I'm not understanding the workaround correctly. Can I create a RealmString once and use it in place of String everywhere that I would need a RealmList of Strings? How would I get RetroFit (REST library from Square) to play nice with such an implementation?
In any case, having this issue resolved would simplify the code and it seems that many people are looking for the same feature. Perhaps the priority of this feature should be increased over something else.
@harish1312 In the documentation (http://realm.io/docs/java/latest/#other-libraries) you can read on how to use Realm with RetroFit and GSON.
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1 This is a very important one.
+1
+1
+1
+1
+1 of course
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
I'll +1 for notifications.
+1
+1
+1
For any Kotlin users out there who don't want to manage a large tree of connected objects, I've been using this.
https://gist.github.com/bclymer/f569fffb41bab046c2d1
It creates a single RealmObject
by storing the Int
s or Long
s as a comma delimited String
. Then it uses an extension function to recreate the List<Type>
+1
+1
+1
+1
In #1652, a workaround was provided until it is supported in realm.
I don't think it was given here, so here it is: https://gist.github.com/cmelchior/1a97377df0c49cd4fca9
+1 like everyone
Thx ;-)
+1
+1
+1
+1
+1
Why isn't this supported until now? Definitely +1
+1
+1
+1 for this essential feature.
+1
+1
A year and a quarter later this issue is still open and has ~75 votes.
Seems like kind of a high important issue.
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
Will implements ? RealmList<RealmString> strings;
retrofit recongnize as object. I Need String
+1
++i
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
This is pretty much the only feature in Realm that's still missing for it to be easy to use for any use-case. I wonder what's up with it.
It's not waiting core anymore, so I wonder what's the hold-up on this one.
+1
+1
@Zhuinden We are currently focusing on support, bugs and P1 issues. Don't worry, we haven't forgot the P2 issues, and we hope to work on them very soon.
+1
+1
@kneth I'm just surprised this is not P1.
++
+1
+1
+1
+1
+1
+1
+1
+1
+1 for the List of primitive
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
How is this still not supported?!?
+1
+1
Can someone from the team lock this conversation until there is some news? For the moment it's just spamming everyone watching.
If someone else want to follow it, there is a "Subscribe" button on the right...
Everyone should really get used to using the nice new smileys in the top description field of the issue :-) But we will Lock this for now.
This feature is among a handfull of top features that we hope to take on next. We will however give the current 1.0 a bit of peace to ensure stability before we push a lot of new features.
Work in Realm Core can be tracked here: https://github.com/realm/realm-core/issues/1881