I just noticed this and thought it was odd behavior.

This code:

OClass oClass = oSchema.createClass("Test");
System.out.println(oClass.isAbstract());
System.out.println(oClass.getDefaultClusterId());

...yields this:

false
9

...but this code:

OClass oClass = oSchema.createClass("Test");
oClass.setAbstract(false);
System.out.println(oClass.isAbstract());
System.out.println(oClass.getDefaultClusterId());

...yields this:

false
3

(9 is the new cluster id created for the class; 3 is the 'default' cluster
id)

Sure enough, here's the code:
https://github.com/orientechnologies/orientdb/blob/2464bb45be6a0a2eba15b3bd5d350b17928e65ff/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OClassImpl.java#L757

Is there a good reason for this? I'm not really sure what the *database's*
default cluster is, but OClassImpl  seems to 1) assume the isAbstract value
was previously true (which it wasn't in my case), and 2) think it's safe to
set the default cluster to the default cluster of the database.
Unfortunately, when I try to insert a record in the class after this point,
I get a "Record saved into cluster default should be saved with class null
but saved with class Test"

Seems like setAbstract(false) should first check if abstract is already
false, and be a no-op. But if it was previously abstract, shouldn't it also
auto-create a cluster for it rather than switch it's default to the
'default' cluster?

- Chris

-- 

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