9

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


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 );
4

1 回答 1

10

只需创建一个类,例如,一个列表。例子:

public class Order{ ... 列出项目;... }

然后:

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 );
于 2011-11-05T21:48:26.203 回答