how to insert date time whenever insert/ update called in realm

672 views
Skip to first unread message

Syed Hassan

unread,
Sep 28, 2015, 4:02:25 AM9/28/15
to Realm Java


I want to synchronize the android application with server. In Server i have maintained last update date through trigger as it uses SQL server but my android application uses Realm so how can i set current date time in a field whenever any row is inserted or updated.

Is there any listener which calls whenever commitTransaction occurs? if yes then i can manually set updated date time on every insert and update. Any suggestion would be highly appreciated.

Syed Hassan

unread,
Sep 28, 2015, 4:04:34 AM9/28/15
to Realm Java
https://github.com/realm/realm-cocoa/issues/2149. this was the exact problem i am facing. but i don't know how to implement it in java.

Kenneth Geisshirt

unread,
Sep 28, 2015, 4:33:42 AM9/28/15
to Syed Hassan, realm...@googlegroups.com
Hey Syed,

You can add an change listener manually, and get notifications. See https://realm.io/docs/java/latest/#notifications for details. Currently, we don't offer fine-grained notifications (we have an open issue: https://github.com/realm/realm-java/issues/989) so you can only get notified that something has changed (object added, removed or updated).

Best,
Kenneth

--
Kenneth Geisshirt
Member of technical staff


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/20824558-c2af-4b2a-b759-5029782002aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:125945124-1944#}

Syed Hassan

unread,
Sep 28, 2015, 4:54:41 AM9/28/15
to Realm Java, sm.ha...@gmail.com, he...@realm.io
 https://github.com/realm/realm-cocoa/issues/2149 . Do we have solution of this problem in java?

Kenneth Geisshirt

unread,
Sep 29, 2015, 5:12:46 AM9/29/15
to Syed Hassan, realm...@googlegroups.com
Hey Syed,

The method Realm.createOrUpdate() might be what you're looking for.


Best,
Kenneth

--
Kenneth Geisshirt
Member of technical staff


{#HS:125945124-1944#}
Reply all
Reply to author
Forward
0 new messages