DB2 Character Datatype and JPA Not Working - jpa

I am working with DB2 Universal database having lots of tables with columns of datatype CHARACTER. Length of these columns is variable (greater than 1 e.g. 18). As i execute a Native query using JPA it selects only first character of the column. Seems CHARACTER datatype is mapped to Java Character.
How can i get full contents in DB column. I can not change the database bening on Vendor side. Please note i need to do it both ways, i.e. :
Using JPQL ( is attribute columnDefinition can work in this case)
Using native DB query (no pojo is used in this case and i have no control over datatypes)
i am using Hibernate implementation of JPA provided by spring.

If these columns are actually common in your database, you can customize a dialect used by Hibernate. See comments to HHH-2304.

I was able to cast the column to VARCHAR to produce padded String results from createNativeQuery:
select VARCHAR(char_col) from schema.tablename where id=:id

Related

SAS SQL Pass-Through Facility does not work as expected for Postgres database

I am working with SCD Type 2 transformation in SAS Data integration Studio (4.905) and using Postgres (12) as database.
I am facing the following error when I try to execute a query via passthrough:
When using passthrough in Postgres, SCD Type 2 doesn't enclose the table name in quotes (which would keep the name uppercase, since postgres converts all unquoted data to lowercase) and so doesn't find it as you can see.
My questions are:
Is there a way to make SCD2 transformation declare the table’s name, used via passthrough, in quotes?
Is there a way to make the SCD2 transformation create intermediate tables ‘name in lower case so that the reference is not lost when doing passthrough?
Is there a global option in DI that allow us to modify/edit temporary table names?
Source and target tables are postgresql tables, with name and columns name in lowercase:
Please, if anyone has faced this problem before or knows what is missing, please, let I know.
To solve this issue, we have to select the following highlighted (source and target) table options. It results in quotes around source/target table names:
Then, SCD2 transformation automatically put quotes in tables y columns names as you can see:

JPA, Postgresql: Is there any performance difference between oid and TEXT?

I'm using JPA with a postgresql database and also using Hibernates hbm2ddl to generate the initial DB schema.
I have a Java String field in my entity object that will need to be large. When I annotate it with #Lob hbm2ddl generates an oid db column, however I can also use #Column(columnDefinition = "TEXT") to get a TEXT db column.
I've tried searching the internet but I can't find any comparison between the performance or other benefits of oid's vs TEXT columns. Is there any reason to prefer one over the other?

Postgres not converting from a java boolean to numeric data column automatically?

I have an Oracle database that is currently being migrated to an AWS Aurora Postgres database. As part of this I have had to update some of the datatypes in our sql files for creating tables e.g. changing NUMBER to NUMERIC etc. It has been going well but I am now coming across the following error when trying to insert some data into a table using spring data/JPA
ERROR: column "some_table_column" is of type numeric but expression is of type boolean
I can identify the issue is probably that the java class defines this column like
#Column(name = "SOME_TABLE_COLUMN", nullable = false)
private boolean someTableColumn;
while the sql file defines it like
CREATE TABLE MY_TABLE
(
SOME_TABLE_COLUMN NUMERIC(1) DEFAULT 0 NOT NULL,
etc..
Don't ask why it has been defined like this, I didn't write this code, I've just inherited it. But this has not been an issue ever with the Oracle database, and I'm only seeing the error now when running against Postgres. Does Oracle do some sort of implict conversion behind the scene that Postgres doesn't do? Is there a way I can resolve this without having to migrate the column to a boolean datatype?

How to map a column to JSONB instead of JSON, with Doctrine and Postgresql?

In my project I'm using Doctrine doctrine 2.5.4/postgres 9.5. I'm trying to add a jsonb field using YAML:
fields:
obj: json_array
This gets interpreted as a json column type (and not jsonb). The specification notes about picking up json or jsonb:
Chosen if the column definition contains the jsonb option inside the platformOptions attribute array and is set to true.
But platformOptions doesn't seem to work (tried to add it below obj, at the top... with no success). How can I add a jsonb field?
This is supported by doctrine/dbal v2.6+ (it requires PHP 7.1). All you need to do is use json_array and set options={"jsonb"=true} I tested this on doctrine/dbal v2.6.3
This is what it looks like in PHP format:
/**
* #ORM\Column(type="json_array",nullable=true,options={"jsonb"=true})
*/
private $details;
and it creates a query such as (for an existing table):
ALTER TABLE mytable ADD details JSONB NOT NULL;
More details about type mapping can be found at Doctrine mapping matrix.
Use boldtrn/jsonb-bundle, it provides a jsonb doctrine type as well as custom functions to access the special operators provided by the PostgreSQL jsonb data type.

Do native queries use naming strategy to resolve the table name in the "from" clause of the given SQL query?

I have a custom naming strategy where I add a prefix to the table names. My question is: when I create a native query (using EntityManager.createNativeQuery) should I use the prefixed name of my tables in the FROM clause of my queries or should I use the non-prefixed name (as in JPQL queries) ??
A Native query is an SQL query, so you input what would execute in your datastore if you put it directly through JDBC. It is nothing to do with the Entities