Reputation: 25892
I have an existing hierarchy of Java classes that represents a model in my application. For example, I have Account<-User Account<-Company classes.
How to store this hierarchy in OrientDB ? Is it possible to automatically create OrientDB Classes based on the existing models ?
Upvotes: 0
Views: 238
Reputation: 9049
OrientDB automatically manages POJO with no need to configure mapping before using it.
// OPEN THE DATABASE
OObjectDatabaseTx db = new OObjectDatabaseTx ("remote:localhost/petshop").open("admin", "admin");
// REGISTER THE CLASS ONLY ONCE AFTER THE DB IS OPEN/CREATED
db.getEntityManager().registerEntityClasses("foo.domain");
// CREATE A NEW PROXIED OBJECT AND FILL IT
Account account = db.newInstance(Account.class);
account.setName( "Luke" );
account.setSurname( "Skywalker" );
City rome = db.newInstance(City.class,"Rome", db.newInstance(Country.class,"Italy"));
account.getAddresses().add(new Address("Residence", rome, "Piazza Navona, 1"));
db.save( account );
For more information look at: OrientDB Object API.
Upvotes: 2