Spring Integration Testing Oracle Native SQL - spring

I have a legacy application that has recently been ported from Struts to Spring MVC. The data layer is written with native Oracle SQL. I'd like to introduce some integration testing but would like to avoid using an actual Oracle database for obvious reasons. Is there an in-memory DB that can deal with Oracle native SQL? Is this just a dream? Am I just going to end up with Oracle XE in a VM?

I've discovered that H2 actually has an Oracle compatibility mode. Great!
spring.datasource.url=jdbc:h2:mem:testdb;Mode=Oracle
spring.datasource.platform=h2
spring.jpa.hibernate.ddl-auto=none
spring.datasource.continue-on-error=true

Isn't Oracle's in-memory database, TimesTen, compatible with standard Oracle?

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.

Is Spring Data Jdbc recommended for Oracle 18c?

Is Spring Data JDBC v1.1.5 recommended for Oracle Database and Enterprise Applications? Lot of samples around the net based on Open Source RDBMS (H2 or PostgreSQL). We are using Spring Data JDBC in a Spring Boot Microservice Application, facing following problems.
Force to write custom converters for oracle.sql.TIMESTAMP, oracle.sql.TIMESTAMPTZ and oracle.sql.DATE and oracle.sql.ROWID etc..
Can't type cast oracle.sql.ROWID to java.lang.Number
Identity must not be null after save.
Spring Data JDBC is absolutely recommended for Enterprise Applications.
Not so much for use with Oracle.
Since the necessary resources (database & JDBC driver) weren't available in a form that could be easily used in integration tests on public platforms, Oracle isn't included in regular builds.
Therefore it is likely that one encounters issues when working with Oracle.
Some are already known, for others issues in Jira or even PRs are highly appreciated.

Spring boot - h2 and Oracle no 100% compatibility

I am using H2 in Spring boot app and Oracle DB on production.
For checking migration files I use FlyWay.
Unfortunately, H2 isn't compatible with Oracle (even if is set Oracle mode).
So, I can't validate my migrations files.
When I have a H2 query - validation in my project is ok, but when I upload it to production - it won`t work on Oracle.
Have you got any ideas how can I validate oracle migration files on my h2-db project?
The Flyway FAQ covers this under db specific SQL:
You can use the flyway.locations property. It would look like this:
TEST (Derby): flyway.locations=sql/common,sql/derby
PROD (Oracle): flyway.locations=sql/common,sql/oracle
You could then have the common statements (V1__Create_table.sql) in common and different copies of the DB-specific statements (V2__Alter_table.sql) in the db-specific locations.
Another approach if the differences are really minor ie only a few keywords, would be to have the keywords that differ as Flyway placeholders:
ALTER TABLE table_name ${alter_column} COLUMN column_name datatype;
TEST (H2): flyway.placeholders.alter_column=ALTER
PROD (Oracle): flyway.placeholders.alter_column=MODIFY

WebLogic and Top Link confusion

I'm trying to install Oracle WebLogic Server, then when I look for the generic version,
TopLink comes up!
What is the deal ? I dont need to integrate my server with TopLink, but I have to if I want the generic version!
Thanks,
Oracle TopLink is an implementation of the Java EE standard for persistence, called "JPA". In fact, the open source version of TopLink is called EcplipseLink, and that is the Reference Implementation for the JPA standard.
Oracle WebLogic uses Oracle TopLink internally to provide its JPA support. For example, Entity EJBs in WebLogic use Toplink for their Object-Relational Mapping (basically, moving the data back and forth from a database to WebLogic). Parts of TopLink are also used for Object-to-XML mapping.
Hope that helps :)
For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.
Are you trying the "Oracle WebLogic Server 11gR1 (10.3.5) + Coherence + OEPE - Package Installer"
Try the "Oracle WebLogic Server 11gR1 (10.3.5) ZIP Distribution" from http://www.oracle.com/technetwork/middleware/ias/downloads/wls-main-097127.html

HSQLDB ROWNUM compatibility with Oracle

THe HSQLDB changelog states that ROWNUM() was added in v2.2.0 which I am using without any problems when running integration tests against the in-memory HSQLDB.
However I want to run the same tests against a real Oracle 10g database, but the query fails because the pseudo-column is called ROWNUM. Is there an easy way write a single query string that works in both environments?
The ROWNUM() function is available by default in HSQLDB 2.2.x and later. If you enable Oracle syntax compatibility mode, you can also use ROWNUM.
This statement enables it:
SET DATABASE SQL SYNTAX ORA TRUE
Or use the connection property sql.syntax_ora=true

Resources