Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAfterDeserialization never called #6551

Closed
1 of 5 tasks
busbaby opened this issue Aug 11, 2016 · 0 comments
Closed
1 of 5 tasks

OAfterDeserialization never called #6551

busbaby opened this issue Aug 11, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@busbaby
Copy link

busbaby commented Aug 11, 2016

OrientDB Version, operating system, or hardware.

  • v2.0 SNAPSHOT[ ] - .18[ ] .17[ ] .16[ ] .15[ ] .14[ ] .13[ ] .12[ ] .11[ ] .10[ ] .9[ ] .8[ ] .7[ ] .6[ ] .5[ ] .4[ ] .3[ ] .2[ ] .1[ ] .0[ ]
  • v2.1 SNAPSHOT[ ] - .16[ ] .15[ ] .14[ ] .13[ ] .12[ ] .11[ ] .10[ ] .9[ ] .8[ ] .7[ ] .6[ ] .5[ ] .4[ ] .3[ ] .2[ ] .1[ ] .0[ ]
  • v2.2 SNAPSHOT[ ] - .rc1[ ] .beta2[ ] .beta1[ ].6[X]

Operating System

  • Linux
  • MacOSX
  • Windows
  • Other Unix
  • Other, name?

Expected behavior and actual behavior

Expected behavior:
The OAfterDeserialization callback should be invoke after unmarshalling. As per http://orientdb.com/docs/2.2/Object-2-Record-Java-Binding.html:
"@OAfterDeserialization called just AFTER unmarshalling the object from the source record"

Actual behavior:
The OAfterDeserialization defined callback is never called.

Steps to reproduce the problem

Please see code below to reproduce.

public class Main {
public static class Foo {

    @Id
    private String id;

    public Foo() {
    }

    public String getId() {
        return id;
    }

    @OAfterDeserialization
    public void fromStream(final ODocument iDocument) {
        System.out.println("here in fromStream");
    }

    @OBeforeSerialization
    public void toStream(final ODocument iDocument) {
        System.out.println("here in toStream");
    }

}

private static void doIt() throws IOException {
    String dbUser = "root";
    String dbPass = "root";
    String dbUrl = "remote:localhost:2424/foo";

    OServerAdmin serverAdmin = new OServerAdmin(dbUrl);
    serverAdmin.connect(dbUser, dbPass);
    if (serverAdmin.existsDatabase("plocal")) {
        serverAdmin.dropDatabase("plocal");
    }
    serverAdmin.createDatabase("document", "plocal");

    ODatabaseDocumentTx databaseDocumentTx = new ODatabaseDocumentTx(dbUrl);
    databaseDocumentTx.open(dbUser, dbPass);

    OObjectDatabaseTx objectDatabaseTx = new OObjectDatabaseTx(databaseDocumentTx);
    objectDatabaseTx.setAutomaticSchemaGeneration(true);
    objectDatabaseTx.getEntityManager().registerEntityClass(Foo.class);

    ORecordId rid = null;
    {
        Foo foo = new Foo();
        System.out.println("about to serialize");
        foo = objectDatabaseTx.save(foo);
        System.out.println("finished serializing foo:" + foo.getId());
        rid = new ORecordId(foo.getId());
    }
    {
        System.out.println("about to deserialize");
        Foo foo = objectDatabaseTx.load(rid);
        System.out.println("finished deserializing foo:" + foo.getId());
    }
}

public static void main(String[] args) {
    try {
        doIt();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

}

The actual output was:
about to serialize
here in toStream
finished serializing foo:#33:0
about to deserialize
finished deserializing foo:#33:0

The expected out was:
about to serialize
here in toStream
finished serializing foo:#33:0
about to deserialize
here in fromStream
finished deserializing foo:#33:0

@lvca lvca added the bug label Sep 23, 2016
@tglman tglman added this to the 3.0 milestone Sep 30, 2016
@lvca lvca modified the milestones: 3.0.0, 3.0.x Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants