How can I use the sql case clause in HQL?

I really need help regarding this one. Here is the code snippet: hSql=" select case when min(start_day_plan) is not NULL then min(start_day_plan) else to_date((min(insertDate)) -...

Changing hibernate batch size programmatically

Is possible to change hibernate.jdbc.batch_size programmatically? I understand hibernate.jdbc.batch_size is a application level parameter, wanted to know if I can use it specifically for certain...

HQL: combine "insert into ... select" with fixed parameters values

I have HQL statement: insert into Item (ost, value, comments, startTime, endTime, proposedBy) select si.ost, si.value, si.comments, si.endTime, si.endTime, u from Item si, User u where si.ost =...

Is HQL converted to SQL in real-time in Hibernate?

I have a basic question in Hibernate. If we use HQL in Hibernate, how is the data fetched from the database? Is it like Hibernate converts the HQL to SQL and executes in database and returns the...

How to use distinct in hql

I am working on a web application using Hibernate, struts and extjs, Here is my scenario. String hql = "from product"; In my product table three columns are there id, name, section I need the...

hql find an entity by collection

I have an Hibernate Entity named User, which has a Set<Book> Book is another Entity having a String bookName; I want to find all Users having an exact list of Books e.g. List<Book> booksList =...

query specified join fetching, but the owner of the fetched association was not present in the select list

I'm selecting two id columns but get error specified: org.hibernate.QueryException: **query specified join fetching, but the owner of the fetched association was not present in the select list**...

HQL like operator for case insensitive search

I am implementing an autocomplete functionality using Jquery, when I type the name, it fetches the record from the db, The records stored in db are mixture of capital & small letters. I have...

How to write a like query in HQL

I want to perform search for a particular string that is starting with a particular alphabet. So, for example if the starting alphabet is 'A' then it should produce a result which will contain all...

When to Use EntityManager.clear()?

A custom JPA mapper class has a method: removeUser() 1. execute 'DELETE' HQL query to remove user 2. call getEntityManager().flush(); 3. call getEntityManager().clear(); If I understand clear()...

how to make HQL that will generate SQL to insert multiple values in one statement?

I need hibernate to generate sql like this INSERT INTO table_a (a_id, a_name) VALUES (5, 'a5'),(6, 'a6');. With sql like that you can add 2 row with 1 statement. I can get a_id,...

HQL merge two typedqueries

I have written two hibernate queries: TypedQuery q = em.createQuery("SELECT user.id FROM TableOne AS user WHERE ...", Long.class); TypedQuery q = em.createQuery("SELECT link.user_id FROM TableTwo...

HQL unexpected AST node: :

My code is failing to inject the below repository. Based on the stack trace, it seems my HQL syntax is invalid, but I'm not sure what I've done wrong. @Repository public interface...

HQL function to extract rows with field contains only number

I've have a little issue to expose: I want to extract from an entity, suppose its name "CustomerDetail" all rows where a specific field (code) has only numeric characters. In HQL doesn't exist...

[Ljava.lang.Object; cannot be cast to

I want to get value from the database, in my case I use List to get the value from the database but I got this error Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object;...

Hibernate, Postgres & Array Type

I'm stuck on a specific issue using array type in postgresql 9.3 mapped with hibernate 4.1.0. This type allows me to have really strong data model, without building lots of tables and joins. In...

Using Hibernate connection with JasperReports

I'm making now a new module into a big one web application. I've created in iReport a report with Hibernate Connection. All Hibernate classes were already made by my teammates, hql query also. So,...

NULL when casting string values to decimal in Hive

I'm using Hive 0.13 and I have in a STRING column of my table values like 1.250,99 I want to cast these values into decimal, so I must replace "." by "" and "," by "." The result would be 1250.99...

Not supported for DML operations with JPA update query

This has been asked once before but the solution did not solve the issue. I am creating a JUnit test: @Test @Transactional @Modifying public void updateMaterialInventory() throws...

How to insert into Hive table with a column of data type array<struct<int>>

I am trying to insert data into a table in Hive I created. I’ve been struggling, so I’m trying to simplify it as much as possible to get to the root of the issue. Here is my simplified code...

unexpected token: LIMIT error in hql

List<AC_Customer> lastAC_CustomersList = session.createQuery("from AC_Customer order by customer_pk DESC LIMIT 1").list() when i execute this i got this error can any one please tell me what is...

How to execute Hive hql files from java?

I understand I can do it by parsing the hql file, extracting individual queries and executing each query separately, but I want to know whether there's a better and more graceful way to run a...

QuerySyntaxException: Unable to locate class

I am using hql to generate an actual Java object of class JunctionManagementListDto. But I end up with the following exception on my console org.hibernate.hql.internal.ast.QuerySyntaxException:...

Getting column names from a JPA Native Query

I have an administrative console in my web application that allows an admin to perform a custom SQL SELECT query on our database. Underneath, the application is using Hibernate, but these queries...

Hibernate DefaultEntityAliases raises NullPointerException

I'm using Spring Boot, Spring Data REST, Hibernate (5.2.12.Final) and I'm exposing my repositories as REST services. I've a problem with a query that raises a NullPointerException and I don't...

Unable to pass positional parameters into HQL query

Whilst trying to create an API for my app I tried to make a query that takes a value passed in and then returns the response from the db. @Query(value = "SELECT u FROM User u WHERE u.userID =...

SQL/HQL - Partition By

Trying to understand Partition By and getting super confused, I have the following data: Name ID Product Date Amount Jason 1 Car Jan 2017 $10 Jason 1 Car Feb 2017 $5 Jason 2 Car ...

Getting "error": "<expression>,<operator>, GROUP, HAVING or ORDER expected got '('"

IntelliJ IDEA Ultimate is showing me an error: <expression>,<operator>, GROUP, HAVING or ORDER expected got '(' right under a braket inside a HQL statement which apperently is not a problem for...

Check count of repeated digits or characters in Hive column

I have a column with numbers in hive. I want to have the count of those rows where digits are repeated and this can be a case for a column of characters also. Eg- Output should be 6. I tried using...

Path expected for join Error for a specific HQL Query (Hibernate)

I get the following error for a HQL query. I can see the path is correct, I fail to understand what is missing here. Can you please help ? I get a Hibernate Path expected for join for the below...