I've converted object to json and converted that into ODocument to save. 
Seems working as I could perform the index based and map based and nested 
queries on the saved record.



doc.fromJSON(new flexjson.JSONSerializer().exclude("*.class","description").
deepSerialize(obj));
 

Thanks

On Monday, June 23, 2014 10:38:55 PM UTC-7, Artem Orobets wrote:
>
> Hi Moksh,
>
> I noticed that you do part of changes outside of transaction and try to 
> save them inside of transaction. It seems not the reason of the problem, 
> but may lead for further problems, so I'd recommend you move 
> populateDocument invocation into transaction.
>
>
> The error tells that OrientDB doesn't know what to do with Item instances. 
> The correct solution in your case would be a modification of 
> populateDocument method to replace such objects as Address or Item with 
> documents and collections of that objects with collection of documents and 
> do that recursively for nested objects.
>
>
> Best regards,
> Artem Orobets
>  
> *Orient Technologies the Company behind OrientDB*
>
>
> 2014-06-23 23:02 GMT+03:00 moksh n <[email protected] <javascript:>>:
>
>> Trying to evaluate OrientDB1.7.3 with Document API for our Analytics.
>>
>> Was able to save all the simple properties along with other class type 
>> properties as simple  ones except the List type. 
>>
>> //Pojo to be inserted
>> public class PurchaseRequest implements Serializable {
>>  private String customerName;
>>
>>  private Address shippingAddress;
>>  private List<Item> items;
>> }
>>
>>
>> //Simplified  DAO api 
>> public String save(Object entity, String storeName) {    
>>      ODocument doc = populateDocument(db, entity, storeName);
>>      db.begin();
>>      doc = doc.save(true); 
>>      db.commit();
>> }
>>
>>
>> //Util method
>>  private ODocument populateDocument(ODatabaseDocument oDatabaseDocument, 
>>  Object entity, String storeName, List<String> excludeKeys) 
>>  throws Exception {
>>      ODocument doc = new ODocument(storeName);
>>      BeanInfo beanInfo = Introspector.getBeanInfo(entity.getClass());
>>      for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
>>        String name = pd.getName();
>>        if (pd.getReadMethod() != null && !"class".equals(pd.getName())) {
>>             Method readMethod = pd.getReadMethod();
>>             Object value = pd.getReadMethod().invoke(entity);
>>             System.out.println("\n name :" + name + " value:"+ value );
>>             doc.field(name, value );
>>        }
>>      }
>>      return doc;
>>  }
>>
>>
>>
>> Throws an error while saving items as an embedded list.
>> Appreciated your help.
>>
>> Cannot serialize the object since it's not implements the 
>> OSerializableStream interface
>> at 
>> com.orientechnologies.orient.core.serialization.serializer.string.OStringSerializerEmbedded.toStream(OStringSerializerEmbedded.java:86)
>>  at 
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.fieldTypeToString(ORecordSerializerStringAbstract.java:218)
>>  at 
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerCSVAbstract.embeddedCollectionToStream(ORecordSerializerCSVAbstract.java:823)
>>  at 
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerCSVAbstract.fieldToStream(ORecordSerializerCSVAbstract.java:520)
>> at 
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV.toString(ORecordSerializerSchemaAware2CSV.java:495)
>>  at 
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.toStream(ORecordSerializerStringAbstract.java:669)
>> at 
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV.toStream(ORecordSerializerSchemaAware2CSV.java:258)
>>  at 
>> com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.toStream(ORecordSchemaAwareAbstract.java:420)
>> at 
>> com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.toStream(ORecordSchemaAwareAbstract.java:415)
>>  at 
>> com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:446)
>> at 
>> com.orientechnologies.orient.client.remote.OStorageRemote.commitEntry(OStorageRemote.java:1931)
>>
>> Thanks
>>
>> -- 
>>
>> --- 
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 

--- 
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