Insert with liquibase failing on H2 with Table not found during startup - h2

I am using liquibase 4.3.3 to insert data to H2 DB using yaml changeset. But, when I try to start the server I get table not found while inserting even though the table exists. But, if I use the generated insert statement and disable liquibase and use spring.sql.init.data-locations to specify the sql file having insert SQL statement, this works. Can you please help me out with this weird problem?

Related

Generate commit for oracle SQL file in liquibase

I want to generate a SQL file via liquibase for my oracle database. Is there a possibility to ensure that liquibase generates a commit; after every changeset? I thought of manually write after every changeset a commit in <SQL> tags but this is actually not a good approach so is there any command for it? I am using liquibase 3.5.5. and generate the SQL file like this:
.\liquibase --url=offline:oracle?
--changeLogFile="C:\Users\Ferid\Documents\Box Sync\PRIVATE_Ferid\liquibase-3.5.5-bin\cl.xml"
--outputFile="C:\Users\Ferid\Documents\Box Sync\PRIVATE_Ferid\liquibase-3.5.5-bin\output.sql"
updatesql

How to rollback database to the original version using Liquibase?

I have an existing database (version x), and I can generate ChangeLog file by using below command
mvn liquibase:generateChangeLog -Dliquibase.outputChangeLogFile=d:\output.xml
After that, I try to remove one table in database directly, How can I user Liquibase to rollback my database to version x ?
Once you have started using Liquibase, you should avoid making changes directly to the database.
Let's simplify the scenario to make it easier to describe. Say at version x your database has a single table called TABLE1 and nothing else. You run the generateChangeLog command, and you get a changelog that has a single changeset that says "create table TABLE1". When Liquibase creates that changeset, it gives it an id. After creating the changelog, you will then want to record in that database that the database and changelog are 'in sync' by running the liquibase changelogSync command - this creates a second table named DATABASECHANGELOG and adds a row to that table with the id of the changeset and some other information.
If you then manually delete the table, Liquibase doesn't 'know' that you have done this, so you would need to also manually let liquibase know that you had done that delete. You would do that by removing the row from the databasechangelog table. You could then re-create the table and get back to version x by running the liquibase update command.

NVarchar2 fields inserted as blank/NULL while Importing data from SQL Server to Oracle over dblink

I'm currently importing data from a SQL Server database into an Oracle 11g one and I'm encountering some strange behavior when importing nvarchar2 columns. The charset on the SQL Server db is Unicode (UTF-8), while on Oracle's side it is not (WE8ISO8859P1).
Whenever i try to import SQL Server nvarchar2 values, Oracle inserts them as blank strings. Trying this on a different IDE, the show up as NULL. Whatever I do, the text is not imported.
I've had success using the dbms_hs_passthrough package, yet this seems overkill for such a simple insert/select task.
What am I missing?
Thanks in advance.
EDIT: If i perform a SELECT on the remote table I can see the text values just fine. CTAS also works as expected. I can only replicate the erroneous behavior when i run the package.
EDIT 2: I've narrowed this problem down to a possible bug in the MERGE statement in Oracle with data from SQL Server over DBLink. I solved this problem by performing separate INSERT/UPDATE DML statements.

Liquibase: Custom SQL statement

I have my liquibase schema defined initially for PostreSQL. Now, I have to modify the schema file to support Oracle. I have a change-set that has a <sql> tag. It has a query that accesses the pg_catalog table to set a value to the sequence. However, this will not work for Oracle. If I remove it, the Liquibase complains with check-sum validation fail. It complains even if I have an empty <sql> tag or some other query specified within. Within this change-set, I have many other create-table statement, so I cannot just remove oracle from dbms attribute. Is there any way I can suppress this sql from running for Oracle?
The dbms attribute on the changeset is the mechanism designed to handle this problem..... Sounds like you're trying to do too much within one changesest (but I guess you've figured that out)
The checksum validation failure is liquibase's safety mechanism designed to defend the database against someone tampering with the schema files.
How to fix it is to use the clearChecksums option when running liquibase. It tells liquibase to recompute the checksums for the changesets already in the database. This will enable your postgres database instance to accept the alterations to its changesets that you've made for Oracle.

Spring-iBatis create database dynamically

I am new to spring-iBatis. I have a requirement to create a database dynamically from my application. The database is MySql. I have seen that there are methods for insert,update and delete like SQLMap.insert(). but I am not finding any method to execute Create statement. Can anyone help me ?
Try using Abator to assist in your code generation.
Hibernate can create a schema for you, because it takes information from objects and mappings and creates tables for you.
iBatis doesn't have the information about tables from mappings; you give it SQL to work with tables that are presumed to exist.
I'd recommend that you add SQL CREATE TABLE statements to a script and execute it with MySQL to create your schema. It should be complete by the time you start with Java and iBatis.

Resources