Morphia Add item to embedded

I have the following structures. Products is embedded in Store; and reviews is embedded in product.

1- Store
  2-Products[]-->
     3-Reviews[]

I am trying to add a new item to review with the following code. It doesn't give me an error but neither does it add it.

Query q1=ds.createQuery(Product.class).filter("Code", code);
if(q1.countAll()==1)
    {
    ops = ds.createUpdateOperations(Product.class).add("Reviews", review);
    ds.update(q1, ops);
    }

Answers


I figured it out. The only was is query for the embedded product, modified it by adding a new review and update that product with ds.CreateUpdateOperations().Set(ops)


Need Your Help

Django - session key of actuall logged user, not possible to get from request

python django forms request session-cookies

How to get the session_key in form Class? It is not possible to get the request parameter to do something like this : request.user

Is it an acceptable practice to enable UnsafeHeaderParsing by default?

.net asp.net asp.net-mvc wcf security

This is a somewhat subjective question, but I'd like to hear the pros/cons for doing this. I manage an open source project called Quick and Dirty Feed Parser and the objective of the project is to ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.