Hi Pascal,

 I had the same problem. I think you can solve as follows.
 After register your models,  you can try to change the field's type to a 
Link type :

Class oClass =db.get().getMetadata().getSchema().getClass(ClassB.class);
oClass.dropProperty("classToBeReferenced");
oClass.createProperty("classToBeReferenced", OType.LINK);

it worked in my case.
Let me know if worked for you.
Best regards,

Robson

Em sexta-feira, 6 de março de 2015 19:05:27 UTC-3, Pascal Klink escreveu:
>
> Hi everyone,
>
>  while playing around with OrientDB 2.0.4 I encountered the following 
> problem:
>
> I have the following (schematic) classes
>
> public class ClassA{
>
>     private String someData;
>     private ClassB embeddedClass;
>
> }
>
> public class ClassB implements Serializable{
>
>     private Integer someData;
>     private ClassC classToBeReferenced;
>
> }
>
> public class ClassC implements Serializable{
>
>     private Boolean someData;
> }
>
> Allthough ClassC should not be embedded but referenced in ClassB, ClassB 
> contains an actual instance of ClassC so that people can easily set an 
> instance of ClassC on ClassB (and not have to deal with OrientDB to get the 
> RID of the instance of ClassC).
>
> The problem with this setup is that OrientDB embeds ClassC in ClassB when 
> an instance of ClassB is serialized. In order to avoid that I created a 
> custom serializer for ClassC:
>
> public class ClassCSerializer implements OObjectSerializer<ClassC, ORID> {
>
>     ....
>
> }
>
>
> My problem is now, that the solution with the custom implementation of 
> OObjectSerializer does not seem to work in verison 2.0.4 anymore, since I 
> cannot find an OObjectSerializerContext where the serializers can be added 
> to. I have orient-core, -client and -enterprise modules in version 2.0.4 on 
> my classpath.
>
> Futhermore, I've tried to solve the problem by implementing 
> ODocumentSerializable with ClassB. But this is not an ideal solution 
> either, since the ODocument, which is created by the toDocument() method is 
> stored as an own entry in the database.
>
> Can anybody help me out here?
>
> Regards, Pascal 
>
>
>

-- 

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