Hi Erik,
On Saturday, December 26, 2015 at 9:43:28 PM UTC+1, Erik Pragt wrote:
>
> Hi all,
>
> Sorry for spamming the mailing list, but I seem to keep running into small 
> issues, and it's hard to find some good documentation. I hope you guys can 
> help me.
>
> I'm trying to save a document:
>
>     public void save(Book book) {
>         try (
>                 OObjectDatabaseTx db = new 
> OObjectDatabaseTx("remote:localhost/demo").open("demo", "demo");
>         ) {
>             db.getEntityManager().registerEntityClass(Book.class);
>
>             db.save(book);
>         }
>     }
>
>
> This works fine. However, when I call the method the second time, I get an 
> error:
>
>
> com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot 
> index record 
> Asin{categoryId:66666,asin:66666,rating:Rating{rating:3.4,numberOfRatings:10},dateProcessed:null}:
>  found duplicated key '66666' in index 'asinIdx' previously assigned to the 
> record #14:101
>  RID=#14:101
>
>
> I don't want to save an extra book, I'd like to update or overwrite the 
> previous book. How can I do this?
>
>
I haven't used Object database, but I would expect it needs a proxy-entity, 
so you would probably need to fetch - update,
see http://orientdb.com/docs/2.0/orientdb.wiki/Object-2-Record-Java-Binding.html
"
You can save a POJO to the database by calling the method save(pojo). If 
the POJO is already a proxied instance, then the database will just save 
the record bounded to it. In case the object is not proxied the database 
will serialize it and save the corresponded record: *In this case the 
object MUST be reassinged with the one returned by the database*
"

hth,
cheers
/m
 

>
> Thanks, 
>
>
> Erik
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to