user1769754
user1769754

Reputation: 23

Sqlite catalog and schema settings (for MyBatis generator)

I have been trying to use the MyBatis generator on a Sqlite database but can't seem to find what settings to use for the XML attributes catalog and schema.

The generator errors with "Generation Warnings Occured: Table configuration with catalog main, schema sqlite_master, and table testTable did not resolve to any tables"

I can't find much from the sqlite website other than this which gives something like catalog = main, schema = sqlite or sqlite_master

My generator XML file is

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration >
  <context id="context">
    <jdbcConnection driverClass="org.sqlite.JDBC" connectionURL="jdbc:sqlite:testDB.sqlite" userId="" password="" ></jdbcConnection>
    <javaModelGenerator targetPackage="model" targetProject="test/src" ></javaModelGenerator>
    <sqlMapGenerator targetPackage="model" targetProject="test/src" ></sqlMapGenerator>
    <javaClientGenerator targetPackage="model" targetProject="test" type="XMLMAPPER" ></javaClientGenerator>
    <table catalog="main" schema="sqlite_master" tableName="testTable" >
      <property name="useActualColumnNames" value="true"/> 
    </table>
  </context>
</generatorConfiguration>

I have also tried other combinations like

<table catalog="main" schema="sqlite" tableName="testTable" >

<table schema="sqlite" tableName="testTable" >

<table schema="sqlite_master" tableName="testTable" >

<table schema="main.testTable" tableName="testTable" >

Anyone here know the right settings?

EDIT:

I have ommited the catalog and schema but still get Generation Warnings Occured: Table configuration with catalog null, schema null, and table testTable did not resolve to any tables"

The error makes me think that MyBatis can't find the table because of incorrect schema, but it could be something else though.

Upvotes: 2

Views: 5940

Answers (3)

AM13
AM13

Reputation: 683

I had this error using docker. The problem was that I though I created a table but in reality I would not have saved it. For example:

Docker for Postgres

docker run -d -p 5432:5432 --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres
docker exec -it my-postgres bash
psql -U postgres


CREATE DATABASE cardcontrol;
CREATE TABLE card(id VARCHAR(32) PRIMARY KEY,external_id integer,pan VARCHAR (50) UNIQUE NOT NULL,card_holder VARCHAR (50),expiration_date TIMESTAMP);

// check creation
\dt

However crating the table in this way I had problem. When I created the table using DBeaver for example (with the same connection used before) the problem was solved.

Upvotes: 0

Mark
Mark

Reputation: 1852

The error message is very misleading, I had it when it turned out the generator couldn't see the db file, so check the file path in the connectionURL entry in the config file.

Upvotes: 1

CL.
CL.

Reputation: 180070

For practical purposes, SQLite does not have catalogs or schemas; omit them.

Upvotes: 0

Related Questions