Hi Erik,
The registerEntityClass(Book.class)does two things:
- register the class for the object database
- check that the class in the schema exists and in case create it
this method does the check for you, this is why it doesn't fail. This
behavior allows you to use existing databases just re-registering Java
classes on existing schema classes.
On the other hand, when you invoke createClass("Book") explicitly, it
throws exception if the class already exists
Thanks
Luigi
2015-12-27 0:44 GMT+01:00 Erik Pragt <[email protected]>:
> Hi all,
>
> Last question for today: why does the following work:
>
> OClass book = db.getMetadata().getSchema().createClass("Book");
> book.createProperty("title", OType.STRING);
>
> db.getEntityManager().registerEntityClass(Book.class);
>
>
> While this doesn't?
>
>
> db.getEntityManager().registerEntityClass(Book.class);
>
>
> OClass book = db.getMetadata().getSchema().createClass("Book"); // <--
> fails, because Book already exists
> book.createProperty("title", OType.STRING);
>
> Why is there no error when I create a class, and then register the entity,
> but when I register the entity, which apparently also creates a class, then
> creating a class is a problem.
>
>
> This seems confusing, and I didn't find any documentation why this could be,
> so if there's a good reason, I'd love to know! I'm just trying to understand
> OrientDB.
>
>
> Thanks!
>
>
> Erik
>
>
> --
>
> ---
> 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.
>
--
---
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.