How data migration works with eclipse store #191
Replies: 3 comments
-
Using EclipseStore to persist data is different to Relational database. There are no tables with rows and columns that represent data. Instead, you work with a java object graph. This graph is your data structure in memory, owned by the application. EclipseStore enables you to persist that graph including updating the persisted state after doing modifications to the graph. Storage targets are used to store the binary blobs created by EclipseStore.
Just rename the constructors parameter “name” to “lastName”. Changes of classes definitions or records are handled by our LegayTypeMapping. It will try to map the fields of an old, persisted version to the current version of a class or record.
Create a new instance of the record using its constructor, add it to the object graph and store the graphs modification.
Remove the object from the graph, store the modification again.
Record can’t be modified, you need to delete the old one and create a new record. The Micronaut project provides some documentation and examples how to do this with Micronaut: How can I access the Eclipse store REST api: To enable the Eclipse Store REST API please see https://micronaut-projects.github.io/micronaut-eclipsestore/1.2.0/guide/#rest |
Beta Was this translation helpful? Give feedback.
-
@hg-ms Create a new instance of the record using its constructor, add it to the object graph and store the graphs modification. How do I do this for PROD data, manually ?? Remove the object from the graph, store the modification again. How do I remove it manually ?? |
Beta Was this translation helpful? Give feedback.
-
Hi, all modifications are done to the in-memory java object graph and a store of the modification. public class MyRoot {
public List<MyRecord> names = new ArrayList<>();
}
public record MyRecord(String name, long id) {}
public static void main(String[] args) {
EmbeddedStorageManager storage = EmbeddedStorage.start();
//set root object if not yet set
if(storage.root() == null) {
storage.setRoot(new MyRoot());
storage.storeRoot();
}
//get the object graph root from the storage
MyRoot myRoot = (MyRoot) storage.root();
//add two new records
myRoot.names.add(new MyRecord("Alice", 0));
myRoot.names.add(new MyRecord("Bob", 1));
//store the modification, in this case the names list has been modified by adding two new elements
storage.store(myRoot.names);
//remove all records with name equals "alice"
myRoot.names.removeIf(r -> r.name().equalsIgnoreCase("alice"));
//store the modification, in this case the names list has been modified by removing one ore more elements
storage.store(myRoot.names);
storage.shutdown();
} |
Beta Was this translation helpful? Give feedback.
-
I am exploring Eclipse Store with Micronaut application since Micronaut has a great integration. I have a few questions related to the Eclipse store -
Public record Student(String name, String address, String lastName);
I am using the GCP function app with Micronaut, where there are three types of function apps.
If I have used the Eclipse store in the Cloud Event function, which will not be publicly available. How can I access the Eclipse store REST api. In the context of the database, the database are not exposed publicly.
Beta Was this translation helpful? Give feedback.
All reactions