Posts

Showing posts from July, 2016

Spring, Hibernate - org.springframework.retry.RetryException: Non-skippable exception in recoverer while processing; nested exception is org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session

Problem: org.springframework.retry.RetryException: Non-skippable exception in recoverer while processing; nested exception is org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session

Solution 1:http://stackoverflow.com/questions/3609653/hibernate-error-org-hibernate-nonuniqueobjectexception-a-different-object-with

Solution 2:This was the one that worked for me. Make sure to create a new object instead of reusing and old one and setting new values into it:


vs


Mongo - Update element inside array

Problem: Update seller.id,  from 1 to 4, inside the offers array:

{
    "_id" : ObjectId("578c7e3c92022220f068d8dd"),
    (...)
    "offers" : { 
        (...)
        "offers" : [
            {
                "productId" : "20001534",
                (...)
                "seller" : {
                    "_id" : "1",
                    "name" : "Mediamarkt"
                },
            }
        ]
    }
}
Solution: db.getCollection(<target_collection_name>).update({"offers.offers.seller._id":"1"},{$set:{"offers.offers.$.seller._id":"4"}}, false, true)
The third parameters tells mongo not to create new documents when no math es are found.The fourth parameters tells mongo to updated all matching documents