How to retrieve generated id in java client

Ricardo Mayerhofer ricardo.ekm at gmail.com
Fri Sep 26 12:26:24 EDT 2014


It worked, thanks!

On Thu, Sep 25, 2014 at 10:51 AM, Brian Roach <roach at basho.com> wrote:

> Hi Ricardo,
>
> When using your own class you'll need to add a String field to it and
> annotate it with @RIakKey. When the response comes back from Riak the
> client will inject the generated key into that field.
>
> Thanks,
> - Roach
>
> On Thu, Sep 25, 2014 at 2:39 AM, ricardo.ekm <ricardo.ekm at gmail.com>
> wrote:
> > Hi,
> > When saving a object with null key using riak's java client is it
> possible
> > to retrieve the generated id?
> >
> > I've found how to achieve this saving a string
> > (
> https://github.com/basho/riak-java-client/commit/7084e30de2c16e3e3d39c06969ae3fc7311b4748
> ):
> > +        Bucket b = client.fetchBucket(bucketName).execute();
> > +        IRiakObject o = b.store(null,
> > "value").withoutFetch().returnBody(true).execute();
> > +
> > +        String k = o.getKey();
> > +        assertNotNull(k);
> >
> > However couldn't figure out how to do this a custom object
> > + MyClass execute =
> > bucket.store(myobject).withoutFetch().returnBody(true).execute();
> > + ??
> >
> > Any help is appreciated. Thanks!
> >
> >
> >
> >
> > --
> > View this message in context:
> http://riak-users.197444.n3.nabble.com/How-to-retrieve-generated-id-in-java-client-tp4031828.html
> > Sent from the Riak Users mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > riak-users mailing list
> > riak-users at lists.basho.com
> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>



-- 
Ricardo Mayerhofer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20140926/5685f9f0/attachment.html>


More information about the riak-users mailing list