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

Restore orginal domain object from persisted snapshot #133

Closed
eladh opened this Issue Mar 19, 2015 · 18 comments

Comments

Projects
None yet
7 participants
@eladh

eladh commented Mar 19, 2015

Currently there is no possiblity to retrive original object or converte it from CDO.
In order to produce some kind of POJO based version management Eco-system we must be able to retrieve the original POJO.

Generally speaking i would love to see Javers with version management API like :

  1. Retrieve the Original POJO
  2. Merge Operation => with Updated/Conflict status
  3. Restore Object to X version

do you Store all Object graph or just Incremental information / diff from the last commit ?

10x

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Mar 23, 2015

well, the bigest problem when we try to restore objects from JaversRepository are references.
Restoring a simple ValueObject is relatively easey, but usually we have a object graph. When you restore one node, you may want to follow references to other objects.
This requires tricky lazy-loading proxies like those in Hibernate ... lot of work

@eladh

This comment has been minimized.

eladh commented Apr 12, 2015

thanks for the explanation :-)
is there any chance for a roadmap - we really want to integrate Javers in our product but needs this features as core functionality.

10x

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Apr 12, 2015

hi, now we are finishing implementing JQL (Javers Query Language)
which is a really big step forward.

Concerning this issue, could you give more details about your requirements?
As I said before, restoring a simple, isolated ValueObject (object without references) is quite easy.
But when you want to restore a whole object graph, things gets complicated ...

@eladh

This comment has been minimized.

eladh commented Apr 17, 2015

Hi :-)
i will check JaversRepositoryReader.
for now i will commit the changes by @entity and isolate the whole object graph .
will try to read the project source code and hopefully write a design doc about it.

10x
elad

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Apr 18, 2015

ok, so we stay in touch, in case if you would like to join our new Javers gitter chat room, we are here:
https://gitter.im/javers/javers

@bgalek

This comment has been minimized.

Contributor

bgalek commented May 8, 2015

first step: we will provide a method to get graph with limited depth, eagerly loaded
ToDo:

  • create InstanceCreator interface available for beeing provided by user
  • javers should try to make object by itself if class has empty constructor
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Dec 10, 2015

@smirnp, it would be better to have this code distributed with JaVers. We can accept Pull Request with this feature, with incubating status, to separate JaVers module, lets say, javers-instance-creator. Would you like to contribute this way?

@smirnp

This comment has been minimized.

smirnp commented Dec 11, 2015

I'll do it

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented May 13, 2016

We have decided to design SnapshotsCompiler feature in a different way. Snapshots will be converted to JSON and then we will use GSon deserialization

@milanov

This comment has been minimized.

Contributor

milanov commented May 13, 2016

Hi @bartoszwalacik , do you have an approximate time frame when this will be implemented, since we've done an incomplete bug-ridden version of this "entity restore" feature and could use a built-in version

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented May 15, 2016

Well, hope it will be released in summer

@mwesolowski mwesolowski self-assigned this Jun 19, 2016

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Jul 5, 2016

this looks like a quite big feature in JaVers. Some support from community would be helpful ... is anyone here eager to contribute?

@rasheedamir

This comment has been minimized.

rasheedamir commented Jan 13, 2017

Hi @bartoszwalacik pretty nice framework! Is there any update on this?

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Jan 13, 2017

No one is working on it.

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Jan 21, 2017

@rasheedamir
I'm thinking about developing this feature. Maybe it will be the next big thing in JaVers ...

@rasheedamir

This comment has been minimized.

rasheedamir commented Jan 30, 2017

awesome @bartoszwalacik let me know if you need assistance; I mean if you have a plan how to implement then I can offer assistance either myself or through one of my team members

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Jan 30, 2017

Good to hear @rasheedamir, your contributions will help us a lot.
I've created a dedicated chat room for this project https://gitter.im/javers/shadows
Please join this chat for quick collaboration.

So how we start?
First, I've already pushed some code to this branch https://github.com/javers/javers/tree/shadows
The simplest case is implemented, take a look at the new test - ShadowFactoryTest.groovy

Design

Looking from users perspective, we are going to add one method to javers:

List<Object> findShadows(JqlQuery query)

Shadow means users domain object restored from a Snapshot.
We need to add a switch to the query

  • shallow shadows - no references reslolved, identifiers to other entities nulled, this query will be fast and implementation will be simple (run findSnapshots() and convert all Snapshots to Shadows, ignoring references)
  • deep shadows - shadows will be created deeply, following references (like Hibernate lazy loading). Reference resolving scope will be limited to original commit scope. This query will be much slower

ShadowFactory implementation

Based on Gson. Snapshots graph converted to JSON (JsonElement) based on users classes structure. Gson deserializes JSON to users objects.

Issues

  • dealing with cycles in object graph
  • dealing with classes without no-arg constructor - see Instance Creators
  • dealing with Class changes. Old snapshots could not fit to current class. Field rename, field type change, field removed
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented May 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment