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

Restore orginal domain object from persisted snapshot #133

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

Restore orginal domain object from persisted snapshot #133

eladh opened this issue Mar 19, 2015 · 18 comments
Assignees
Labels

Comments

@eladh
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
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
Copy link
Member

@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
Copy link

smirnp commented Dec 11, 2015

I'll do it

@bartoszwalacik
Copy link
Member

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
Copy link
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
Copy link
Member

Well, hope it will be released in summer

@mwesolowski mwesolowski self-assigned this Jun 19, 2016
@bartoszwalacik
Copy link
Member

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

@rasheedamir
Copy link

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

@bartoszwalacik
Copy link
Member

No one is working on it.

@bartoszwalacik
Copy link
Member

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

@rasheedamir
Copy link

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
Copy link
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
Copy link
Member

done and released in 3.2.0
see http://javers.org/documentation/jql-examples/#query-for-shadows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants