How to convert this sql query to JPA criteria - postgresql

I would like to do a string search on all the columns in my table or view in my database.
Below is my SQL query.
SELECT *
FROM MY_FAVORITE_MOVIES as t
where t::text like '%srk%'
The above query would do a search of the string in all the columns of the table.
How to do the same with JPA criteriaBuilder API?
I tried using the like operation but it seems like I have to do a string search for each and every column. Is there a way to do a search string in all columns at once.

No, this is not possible with JPA. You must query all fields separately. Or you may just trigger your SQL query as a native query from JPA.

Related

Does the Oracle NoSQL Database SQL query support slice for an array?

One of our applications stores a number of arrays in a table. We need to query these arrays in many different ways.
Does the Oracle NoSQL Database SQL query support the following?
Simple examples:
Let's assume the following is part of the table myTable:
myarray array(integer)
We need to implement the following queries:
SELECT username, myarray[1] AS t FROM myTable
SELECT username, [myarray[0:2]] AS t FROM myTable
Yes, both queries are supported.

How to delete records using jdbcTemplate. Query where clause with like clause

I want to delete huge data (above 100K) from table using spring jdbcTemplate. Where clause contains like. eg. DELETE from TABLE_NAME where NAME like 'ABC%'. If possible how to use batching. Please suggest. thanks

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

entity framework map one model to many table

I store data in table named by month,such as data201201,data201202 and so on,table is created in the first day of month,all tables have same struct.I design this because each month ten million rows increase and I have only sqlserver standard version so Partition table can not be used.
Before use entity framework,i used sql string to query data,so I can change tablename in sql string by query condition.
Is these any way that I can query related table in Entity Framework?
I have two idea:
1.another table design that can support such big data and minor cost?
2.Intercept ef's query and change table name by query condition,and continue this query,but how and where i can do so?

DB2 Character Datatype and JPA Not Working

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