The short answer is no, there is nothing that can fulfil your requirements

We developed something similar for PostgreSQL, we call it Hybrid DAOs, basically each POJO is annotated as Riak KV and also as Eclipselink JPA entity, I can only give you partial code and some hints.

You need a standard ORM, Eclipselink IMHO is perfect, faster, simpler and less cluttered than Hibernate, then using JPA interceptors you should be able to read/write your Object from Riak and the DB at the same time, finally, you need a cloning policy and use some hacks to make JPA write back, if you modify a non-mapped JPA property, it won't write back and hence won't call the interceptor, sample interceptor:

   public class JPA2RiakListener<K extends Comparable, T extends
   RiakKeyValue<K, T>>
   {
      @PostLoad
      @SuppressWarnings("unchecked")
      public void onLoad(final T target) throws Exception
      {
        final RiakKeyValue<K, T>
   
keyValue=getDAOFor(target.getClass()).fetchKeyValue(target.getKeyName(),target.getId());
        if(keyValue != null){
          JPAQueryUtils.copyNotNullProperties(keyValue,target);
        }
      }

      @PostPersist
      @PostUpdate
      @SuppressWarnings("unchecked")
      public void onPersistOrUpdate(final T target) throws Exception
      {
        ((RiakDAO<K, T>)
   getDAOFor(target.getClass())).saveKeyValue(target);
      }

      @PostRemove
      @SuppressWarnings("unchecked")
      public void onRemove(final T target) throws Exception
      {
   
getDAOFor(target.getClass()).deleteKeyValue(target.getKeyName(),target.getId());
      }
   }

Also, you need your mapped POJO's annotated with some clone policy, a clone policy will make sure non-mapped properties will be replicated, say, a column that is mapped to Riak but not mapped to your relational DB.

   @Entity
   @Table(name="foo")
   @EntityListeners(JPA2RiakListener.class)
   @CloneCopyPolicy(method="cloneThis",workingCopyMethod="cloneThis")
   public class Foo extends RiakKeyValue<Integer, Foo> {
       ...
   }

Sample cloneThis() method:

     public RiakKeyValue<K, T> cloneThis() throws Exception
     {
       @SuppressWarnings({"unchecked"})
       final RiakKeyValue<K, T> result=this.getClass().newInstance();
       JPAQueryUtils.copyNotNullProperties(this,result);
       return result;
     }

Hope that helps,

Guido.

On 05/02/14 10:06, Ajit Prasad(RMG00) wrote:

Hi,

We have a requirement for pulling Oracle data as JSON and putting the same in RIAK db. Didn't find any suitable RIAK API in RIAK docs. Pls. let me know whether any API or any third party tools which can perform the above activity.

Thanks and regards,

Ajit

Cell:+91-9980084384


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Disclaimer~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Information contained and transmitted by this e-mail is confidential and proprietary to iGATE and its affiliates and is intended for use only by the recipient. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or use of this e-mail is strictly prohibited and you are requested to delete this e-mail immediately and notify the originator or mailad...@igate.com <mailto:mailad...@igate.com>. iGATE does not enter into any agreement with any party by e-mail. Any views expressed by an individual do not necessarily reflect the view of iGATE. iGATE is not responsible for the consequences of any actions taken on the basis of information provided, through this email. The contents of an attachment to this e-mail may contain software viruses, which could damage your own computer system. While iGATE has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening an attachment. To know more about iGATE please visit www.igate.com <http://www.igate.com>. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to