Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: How to store List<Object> in OrientDB?

Tags:

java

orientdb

Is there a sample code that shows how to store and retrieve List fields?

like image 737
KJW Avatar asked Nov 05 '11 16:11

KJW


1 Answers

just create a class with, for example, a List. Example:

public class Order{ ... List items; ... }

Then:

ODatabaseObjectTx db = new ODatabaseObjectTx("local:/temp/db");
db.create();

db.getEntityManager().registerEntityClass(Order.class);
db.getEntityManager().registerEntityClass(OrderItem.class);

Order o = new Order(234);
o.items = new ArrayList<OrderItem>();
o.items.add( new OrderItem('mouse', 10, 12.5) );

db.save( o );
like image 189
Lvca Avatar answered Sep 19 '22 14:09

Lvca