title: Inserting into embedded list of orient db through java
body: <p>This is the sql script that I have used to create the necessary classes :</p>
  <pre><code>CREATE CLASS ProductSummary;
  CREATE PROPERTY ProductSummary.name STRING (NOTNULL, MANDATORY TRUE);
  CREATE PROPERTY ProductSummary.modelNumber LONG (NOTNULL, MANDATORY TRUE);
  ALTER CLASS ProductSummary STRICTMODE TRUE;
   
  CREATE CLASS PricingSummary;
  CREATE PROPERTY PricingSummary.price LONG (NOTNULL, MANDATORY TRUE);
  CREATE PROPERTY PricingSummary.discount LONG (NOTNULL, MANDATORY TRUE);
  ALTER CLASS PricingSummary STRICTMODE TRUE;
   
  CREATE CLASS TotalSummary EXTENDS V;
  CREATE PROPERTY TotalSummary.projectLink LINK Project (NOTNULL, MANDATORY TRUE);
  CREATE PROPERTY TotalSummary.productSummaries EMBEDDEDLIST ProductSummary;
  CREATE PROPERTY TotalSummary.pricingSummaries EMBEDDEDLIST PricingSummary;
  ALTER CLASS TotalSummary STRICTMODE TRUE;
  CREATE INDEX TotalSummary_projectLink_idx ON TotalSummary (projectLink) UNIQUE;
  </code></pre>
  <p>I am trying to insert some values into my TotalSummary class, where I also need to insert some values into the EmbeddedList for pricingSummaries and productSummaries.</p>
  <pre><code>public TotalSummary create(final TotalSummary totalSummary) {
          final Long projectId = 1;
          final StatementBuilder builder = new StatementBuilder();
          final StringBuilder query = new StringBuilder();
          
          final List&lt;Map&lt;?, ?&gt;&gt; productSummaries = totalSummary.getProductSummaries().stream()
                  .map(ProductSummary::toMap)
                  .collect(Collectors.toList());
          
          final List&lt;Map&lt;?, ?&gt;&gt; pricingSummaries = totalSummary.getPricingSummaries().stream()
                  .map(PricingSummary::toMap)
                  .collect(Collectors.toList());
          
          
          builder.addAttribute(&quot;projectLink = (SELECT FROM project WHERE id = ?)&quot;, projectId);
          if ( ! productSummaries.isEmpty()) {
              builder.addAttribute(&quot;productSummaries = ?&quot;, productSummaries);
          }
          if ( ! pricingSummaries.isEmpty()) {
              builder.addAttribute(&quot;pricingSummaries = ?&quot;, pricingSummaries);
          }
          
          try {
              insert(TotalSummary.class.getSimpleName(), builder.attributes(), statement -&gt; {
                  builder.init(statement);
                  return statement;
              });
          } catch (final UncategorizedSQLException e) {
              throw new ConstraintViolationException(totalSummary, ExceptionUtils.getRootCauseMessage(e), e);
          }
  
          return assertNotNull(findById(projectId));
      }
  
  This is the utility method that I am using to build the insert query : 
  protected String insert(final String vertex, final String fieldValuePairs, final PreparedStatementInitializer initializer) {
      final String sql = &quot;INSERT INTO &quot; + vertex + &quot; SET &quot; + fieldValuePairs + &quot; RETURN @rid&quot;;
      return executeStatement(sql, initializer);
  }
  
  The toMap methods to convert the List&lt;ProductSummary&gt; to List&lt;Map&lt;?,?&gt;&gt;
  
  **ProductSummary**  
  public Map&lt;String, Object&gt; toMap() {
      final Map&lt;String, Object&gt; ret = new HashMap&lt;&gt;();
      ret.put(&quot;name&quot;, name);
      ret.put(&quot;model number&quot;, Long.valueOf(modelNumber));
      return ret;
  }
  
  The toMap methods to convert the List&lt;PricingSummary&gt; to List&lt;Map&lt;?,?&gt;&gt;
  **PricingSummary**
  public Map&lt;String, Object&gt; toMap() {
      final Map&lt;String, Object&gt; ret = new HashMap&lt;&gt;();
      ret.put(&quot;price&quot;, Long.valueOf(price));
      ret.put(&quot;discount&quot;, Long.valueOf(discount));
      return ret;
  }
  
  
  </code></pre>
  <p>I am getting the following exception when I execute the code</p>
  <pre><code>Constraint violation for: TotalSummary@58f79eeb[recordId=&lt;null&gt;,customProperties=[]]. Reason: OValidationException: The field 'TotalSummary.productSummaries' has been declared as EMBEDDEDLIST but an incompatible type is used. 
  
  </code></pre>
  <p>Things that I have already tried :</p>
  <ol>
  <li>I have tried to covert to list to json format before adding it to
  the builder like so new Gson().toJson(pricingSummaries);</li>
  <li>Converted the pricingSummaries and productSummaries toArray().</li>
  </ol>