Update all schemas with multitenancy architecture - java

I have a Java Web project with multitenancy using Hibernate, Spring and JPA. We recently implemented the architecture multitenancy but we don't know how update all the schemas of the database. Before that, when we didn't have this architecture we set in the persistence.xml the property hibernate.hbm2ddl.auto with update, but now it isn't possible because we have more than one schema. Do you have a solution?

Try using FlywayDB instead of hibernate.hbm2ddl.auto which shouldn't be used in production anyway. An incremental schema update can provide you a guarantee that the product environment can be safely updated, once you tested the incremented scripts on a QA server.

Related

Where to deploy Spring boot application with H2 database

I am working on a web application which will serve as an SQL injection learning platform with multiple levels in spring boot and react. I am using PostreSQL as my main database, but I also wanted a lightweight solution for a vulnerable database on which the injections will occure. I was going to choose H2, but it isn't supported on Heroku where I wanted to deploy my application, as I worked with it in the past and it's already familiar.
So the question is: What other platform could I use to work with H2 or should I choose something else instead of H2, and if yes, what?
The way I handle this is to use spring-bean "profiles"
default
or
!default
I use H2 all the time for local-development mode (using 'default' spring bean profile to achieve this).
Now, we do not over-use spring-profiles. We have default and !default. And that is is.
All my JPA stuff works with H2.

Spring Framework - Using only JPA data repositories in existing application

I have an existing application which I want to extend by an embedded database. I have some experience with 'raw' derby (writing the sql statements by myself). For this application I use eclipse with maven but no additional framework for the application itself.
I have no experience with the spring framework but I came accross JPA data repositories (spring-data-jpa from org.springframework.data) which seems for me the way to go. But is it possible to use for the moment for this application only the data repositories of spring? Or will this lead to changes in the existing Code as one can not use only the data repositories alone?

Is it possible use Flyway to perform NoSQL migrations?

Flyway can be configured to execute migrations on a NoSQL database (i.e. via Java API) or it is designed only for relational databases?
There is no explicit support at this time. What you can however do is use Flyway in combination with both a relational and a NoSQL db. Flyway would then keep its metadata table in the relational DB and you would write Java migrations to migrate the NoSQL datastore.
An alternative to flyway for MongoDB migration is Monjam (https://github.com/oun/monjam). It has gradle plugin to run the migration. You can write migration in java or js script.

can JPA and memcached be used simultaneously in a web application? how?

i am developing a web application and for Object relation mapping i am using JPA.
My application frequently reads from DB.
to speed up the DB reads can i use memcached along with JPA? what's the machanism?
i am using JPA with eclipselink, eclipse and weblogic.
Only place JPA and memcached will relate through an API I can think, if you are using hibernate, is caching. If you are using Hibernate you may configure memcached as your 2nd level cache provider by using the hibernate-memcached project. Though I believe there are better alternative than memcached if you are just planing to use it as a hibernate 2nd level cache.
Memcached is an in memory caching system which you may use as a db it self.

How to access the development database with the Play! framework?

I want to see the tables of my Play! application with the H2 console, but all I see is a list of internal tables of the db engine. How can I view the tables of my application?
Log on to the JDBC URL jdbc:h2:mem:play instead. That is where the development database runs on at least on my Play instance.
Most likely, you are looking a different database. Could you verify the database URL is really jdbc:h2:~/play?
You should also consider upgrading to a more recent version of H2. The version you are using (1.3.149) is a beta version.

Categories