Getting H2 MVStore when using JPA - h2

I use JPA in my application to utilize the H2 database. Now I'd like to get my hands on some internals of the H2 – the MV Store. What I currently have is JPA's EntityManager.
I'd like to run some special commands like compactMoveChunks() or getCurrentFillRate().

Related

what is the best way to create session from java spring boot using oracle Database?

I created user in oracle database and I am trying to create session but I find many ways in spring boot so what is the easy way if I want to create classe connections using the Username and Password ?
You can jdbc template, spring data JDBC or spring data JPA, well depending on your use case.
If your data model is quite complex, you should avoid using the JDBC template as you will need to write prepared statements which can be cumbersome. JPA will allow you to use object-oriented programming principles and also will help you map the entities to your database columns.
For example, if you are going to use spring data JPA, you need to set the application properties as follows:
spring.datasource.type=oracle.oracleucp.jdbc.UCPDataSource
spring.datasource.oracleucp.connection-factory-class-name=oracle.jdbc.pool.OracleDataSource
spring.datasource.oracleucp.sql-for-validate-connection=select * from dual
spring.datasource.oracleucp.connection-pool-name=UcpPoolBooks
spring.datasource.oracleucp.initial-pool-size=5
spring.datasource.oracleucp.min-pool-size=5
spring.datasource.oracleucp.max-pool-size=10
This would behind the scene create an Oracle Datasource. In this example, we are using Oracle Universal Connection Pooling. You can also use HikariCP which is quite popular.
check this out
If you want to use UCP with above properties then you must have SpringBoot version higher than 2.4.0.
Check out the Spring Boot code sample on GitHub.

Can we use multiple datasources with jdbi in spring boot project

Can we use multiple datasources with jdbi.
Will the configuration will be same as what we have with JPA : https://www.baeldung.com/spring-data-jpa-multiple-databases
So, in first, you can set more than one database for your application with JDBI, exactely like JDBC. You just have to set them inside your application.properties.
Second, if you want to use JDBI, you'll use a kind of classical queries, instead of a dialect for JPA/hibernate inside repositories.
You can read this discussion to compare them : Benchmarking spring data vs JDBI in select from postgres Database

Is it possible to implement read through and write through in apache ignite using jpa?

I wanted to read and write data from underlying db with Apache ignite . I'm doing a spring boot app so i just want to know whether i can use JPA features for it ?
As far as my understanding goes, Apache Ignite does not implement any JPA APIs. So you can't access data stored in Ignite in JPA fashion.
However, you can probably use JPA to cache data in Ignite while writing it to, and reading from, underlying JPA store. In this case you will need to implement your own CacheStore. Example: https://github.com/gridgain/gridgain-advanced-examples/tree/master/src/main/java/org/gridgain/examples/datagrid/store (this is based on Mongo but you can rewrite it to use JPA).

Spring JDBCTemplate and Hibernate

I have a Spring, Spring Data, JPA/Hibernate application.
The legacy part of the application uses JdbcTemplate the new stuff uses spring-data/hibernate and everything is wrapped in a transaction.
Problem is when I modify an entity via hibernate and the legacy part of the system attempts to query something that's been modified I don't get the updated values with out having to explicitly "flush" the entity manager each time.
Is it possible execute the JdbcTemplate queries against hibernate's first-level cache?
What about trying this?
Edit: https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/orm/jpa/JpaTransactionManager.html
This transaction manager also supports direct DataSource access within a transaction (i.e. plain JDBC code working with the same DataSource). This allows for mixing services which access JPA and services which use plain JDBC (without being aware of JPA)! Application code needs to stick to the same simple Connection lookup pattern as with DataSourceTransactionManager (i.e. DataSourceUtils.getConnection(javax.sql.DataSource) or going through a TransactionAwareDataSourceProxy). Note that this requires a vendor-specific JpaDialect to be configured.

Spring Boot app testing with database vendor specific JPA annotation

I got an app with an existing database that has Oracle only field type (e.g. "binary-float") mapped on the entity class with #ColumnDefinition annotation.
Things runs fine when running the app normally by launching the Application class.
However I can't seem to find a way to write junit tests easily. In another Spring Boot app, I have been using different profile to define a normal datasource that points to Oracle and a junit test datasource that points to the h2 in-memory db. I stayed mostly within JPAQL and common sql standard when using direct sql. Problem is, this scheme doesn't work if the JPA mapping annotation is database specific.
Any suggestions?

Resources