how to use jpaReposotory methods with an exist database? - spring

who can help me to understand this scenario please. let say there is a client who have been using php as Backend, now he wants to merge his project from php to Spring knowing that he already has a full data and completly defined (mapping, primary key, tables), he export his data as sql (database.sql) so my question is how can we work and interact with this data in Spring Data ?

So you have the database export file(s), you create a new empty database and import those files there, configure your Spring Data to connect to the new db and stop using the Php app if you can (if you continue to use it you will have to somehow synchronize the two databases, more complicated)

Related

How to migrate from one backing store to another

I need to figure out a way to migrate our Javers audit data from DocumentDB to another independent repository than our domain data.
Does javers currently have any mechanism we can use to take our existing data and insert it properly into a second DB without having to manually map the data?
There is no migration tool. There are two javers' collections in MongoDB: jv_snapshots and jv_head_id, it's easy to copy them manually.

Is there a need in Neo4j to have initial scripts just like rdbms store needs initial CREATE(and other DDL scripts) scripts to insert,update etc?

I recently was working with liquibase which is capable of generating the initial DDL script for my JPA entities.
I am trying to do the same for my entities which has Neo4j as the store. Is there any library like liquibase which I can use to get my work done. Can someone put light on this ?
Is there a need in Neo4j to have initial scripts just like rdbms store needs initial CREATE(and other DDL scripts) scripts to insert,update etc ?
I don't want to use the auto capability of spring boot.
There is no need in Neo4j to create or update schema itself, as you're doing in SQL. Schema is dynamically builds from the data you have in your database.
But if you're trying to manage migration of the data stored in your database, you can take a look at liquigraph. It's able to manage a CYPHER queries within changesets.

Howto make starter content in Spring boot?

I using JPA and MySQL in Spring boot. Howto make a initial content data of database?
Example, need create the basic sections, default admin user, etc.
Thanks.
I would recommend that you take a look at Flyweight, It is nicely integrated into SpringBoot.
We use it to create the initial database, and for adding new tables or modifying the database when deploying new version of our application.
I would recommend that you create a script /resources/db/migration/V1__Initial.sql Which just have the table layout and then a V2__data.sql with the initial data.
A script can only be run once, and you can't modify it after it has been run, this information is stored in a table named schema_version, which you will probably have to delete, or manipulate during development. Here is a link
to how it works - These days I would never do a real world project without using it.

Parse.com sync data from an account to another

I'm trying to sync the data between parse.com account (which is production) to another parse.com (which is development). Any ideas? I have found a way to export the production into CSV, but I can't import it with the relations and pointers.
Due to import function seems not supported, you should try to duplicate your mongodb from prod to dev.
First, following the migration guide(db part) point the db by your uri. Second, duplicate the prod db to another db, and get another uri. Third, create new Parse APP with this uri.

How to load a H2 database into memory?

I have written a set of unit tests using H2 in embedded mode. Whatever changes tests make to DB stay there.
I know that the recommended approach is to create a blank in-memory database and create the schema when opening the connection.
However I am looking for an alternative approach. I would like to -
Initialize an in memory database with an embedded database file.
Or use embedded db in a way that all the changes are discarded as soon as the connection is closed.
How can I achieve this?
What I do in cases similar to this is to write the SQL script that creates the database and populates the tables. Then the application applies a database migration using Flyway DB.
Other possibilities are to create the database and load the tables from CSV files. The other would be to create the database with a different application and create a file with the SCRIPT command to create a backup. Your main application would have to run the RUNSCRIPT command to restore the database.
I use SQL scripts that create tables and other objects and/or populate them, and run these scripts at the beginning of the application.
One could also create a copy of the populated on-disk DB, package it into a ZIP/JAR archive, and open it read only, to be used to recreate and populate the in-memory DB.

Resources