Questions tagged [hql]

1

votes
0

answer
9

Views

In hive, how to generate dynamic table name in hql?

i want generate dynamic table name in hql which runing using beeline. in db2, i can implement this requirement using ||. for example, using year to generate table name 'as400.trxfintrx_' || year(current date), but how can i implement this in hive'hql?
BlackMamba
0

votes
0

answer
5

Views

Incorrect syntax near ')' in hibernate named query

I am facing an error mentioned above, while fetching a list of values in a named query. Here is the HQL syntax for this: select rolepermis0_.permission_name as col_0_0_ from role_permission rolepermis0_ where rolepermis0_.role_id in () and here is the named query syntax i am using: @NamedQuery(name...
Manoj Majumdar
0

votes
0

answer
3

Views

NHibernate QueryOver syntax with multiple tables

I have some problems with NHibernate QueryOver Syntax. I am not able to convert the following SQL to NHibernate QueryOver Statement: "select m.* " + "from authmodule m inner join authmoduleassignment ma on m.Id = ma.module_id " + "inner join authroleassignment ra on ma.role_id = ra.role_id " + "inn...
1

votes
1

answer
10k

Views

How to query struct array with Hive (get_json_object) or json serde

I am trying to query the following JSON example file stored on my HDFS { "tag1": "1.0", "tag2": "blah", "tag3": "blahblah", "tag4": { "tag4_1": [{ "tag4_1_1": [{ "tag4_1_1_1": { "Addr": { "Addr1": "blah", "City": "City", "StateProvCd": "NY", "PostalCode": "99999" } } "tag4_1_1_1": { "Addr": { "Addr1...
DatWunGuy102
1

votes
1

answer
724

Views

JPQL query delete not accept a declared JOIN?

I'm trying to understand why the Hibernate not accepts this follow JPQL: @Modifying @Query("delete from Order order JOIN order.credit credit WHERE credit.id IN ?1") void deleteWithListaIds(List ids); The error that I receive is: Caused by: java.lang.IllegalArgumentException: node to traverse cannot...
Dherik
1

votes
1

answer
7

Views

hql query outer join

Hi everyone I am trying to do an outer join using hql and iterate the retrieved columns to display it. the code below shows no error and also no outputs.
Khalid Kbashy
1

votes
2

answer
3.8k

Views

HQL and checking if object is null or object field have specific value

I have problem with executing following query: from Customer c where c.connectedUserID = 1 and (c.connectedFinancialAnalyst is null or c.connectedFinancialAnalyst.completed = false) object c.connectedFinancialAnalyst can be null. What I need is to find Customers that dont have financial analyst or p...
s7474
1

votes
3

answer
1.3k

Views

Java Hibernate select count with other columns

My HQL code: select count(products.id) ,products.id, products.productDescription, p.products.productFileName from Polls as p group by products.id order by count(products.id) desc This query returns Coloumn 1 | Column 2 | Column 3 | Column 4 3 | 2 | Product1 | ProductFilename1 2...
Thinker
1

votes
3

answer
1.6k

Views

Hibernate query: could not resolve property

I'm getting the following error when trying to run this Hibernate query: could not resolve property: candidateID of: result [select SUM(A.Points) from answer A Left Join A.Results R where R.candidateID = '465b4eb2-c306-4092-8914-d272b5a70b11'] QueryString select SUM(A.Points) from answer A Left...
Prometheus
1

votes
3

answer
1.1k

Views

How to make update faster with Hibernate while using huge number of records

I am facing issue while using the hibernate update (Session.update()) portion with huge number of records. it is becoming very slower. but there is no issue with the insert (Session.insert()) portion. is there any way to do the update portion while we do update on lakh's of records.is there any way...
Saif
1

votes
4

answer
382

Views

The greatest row per group - further combining the result set with left join with other related table in Hibernate - HQL. Is it possible?

There two tables in my Oracle database product and product_image. They have one-to-many relationship from product to product_image. Therefore, the relationship can be mapped in Hibernate something like the following. The product entity: @Entity @Table(name = "PRODUCT", catalog = "", schema = "WAGAFA...
Tiny
1

votes
3

answer
215

Views

Grails querying the database against a list of objects

I'm creating an application with Grails. I have two domain classes: parent and child: class Parent { string name hasMany[children: child] } class Child { string name belongsTo[parent: parent] } I search for all the parents with a name similar to a keyword: def parents = Parent.findAll("From Parent a...
Jacopo
1

votes
2

answer
279

Views

How to check date and time individually in Mysql?

In my SQL table have column like startDate - DATETIME(data type) And it gives format like `2013-08-08 06:30:00` And i have two fields dateonly - 2013-08-08(value) timeonly - 06:30:00(value). Now i want to query to check these two fields values with database value. Hear two comparisons first check...
java
1

votes
2

answer
55

Views

Retrieve database value based on year?

I have a table named as holidays i want to filter the row based on the year. My database table look like this, 2013-09-25 2013-09-12 2014-01-15 2014-05-15 i want only the column values whose year starts with 2013?
PS Kumar
1

votes
1

answer
54

Views

How to write that HQL right

Hi I am trying to write this where and fetch query and I get an error Query query = session.createQuery("from Device d where d.customerRefId=:customerId " + "left join fetch d.tradeInOldDevice "); query.setParameter("customerId", "myId"); Set customerDevices= (Set) query.list()...
rayman
1

votes
1

answer
4.1k

Views

Hibernate LEFT JOIN HQL query not counting correctly with condition

I am using the following HQL: SELECT lo.id, lo.priority, COUNT(p.id) FROM LoadingOrder AS lo LEFT OUTER JOIN lo.palettes AS p WHERE SUBSTRING(p.space.id, 1, 1) = 'B' The problem is it doesn't show me loading orders without palettes. Without the WHERE clause it shows loading orders without paletts (...
GUZ
1

votes
3

answer
1.2k

Views

How to insert all rows in a single statement

How can I insert all rows in a single statement. Here is my code but It takes to long to insert rows. for(Myobject object : objectList) getCurrentSession().save(object); It creates a statement for every record; insert into myobject (id, type) values (?, ?) insert into myobject (id, type) values (?,...
hellzone
1

votes
1

answer
1.1k

Views

Hibernate query syntax error?

from (From FlightSchedule as a where a.route.routeId=1) as b What is wrong in above query? It gives me this error org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 6 [from (From FlightSchedule as a where a.route.routeId=1) as b] I have tried to write it in...
Amit Kumar
1

votes
2

answer
6.3k

Views

Pass hive a createTables.hql in batch mode

I have created a huge createTables.hql file. However, I would like to give hive the file in batch mode to save a lot of time at implementation. I tried % hive -f createTables.hql, however, that does nothing when saved in an *.sh file I appreciate your answer!
Anna.Klee
1

votes
2

answer
776

Views

Hibernate HQL - include columns from PK into query

I've used Spring Roo to reverse engineer an existing database in order to get hibernate modelling on the existing database, in the cases where composite primary keys exist, it generates XyzClass and XyzClassPK. If I want to do an HQL query on some of the columns that are part of the composite primar...
Jan Vladimir Mostert
1

votes
3

answer
375

Views

How to make my query selection faster over a 2 million records

Here i need a solution for my problem. I have a table that contain 2 million records related with geo coordinates. To get a perticular row from the table, query execution time will be 24 seconds. Here i want a selection of above 500 records for my application aspects. So any one kindly suggest any...
1

votes
1

answer
3.8k

Views

Error with Hibernate HQL - unexpected token:

***import org.hibernate.Query;*** String hql = "FROM :className WHERE userCreate like ':userName'"; Query query = session.createQuery(hql); query.setParameter("className", className); query.setParameter("userName", userName); List result = query.list(); And have an error org.hibernate.hql.internal.a...
Rua Tahi
1

votes
2

answer
967

Views

HQL-Select from 2 tables

I am a beginner in Hibernate. I want to select data from two tables using hql. the problem is that the query gives me result if I select one object like this example: (select d from eresa e, dresa d where e.f_ideResa = d.eresa.f_ideResa and e.F_DATEFROM=:x) but when i want to select multiples dat...
BelGhith Ahmed
1

votes
1

answer
8.7k

Views

Using CAST(columnName AS INT) in HQL

I'm using Hibernate 4 and Postgres The following query is a join of two tables where I need to cast a column that is varchar to integer for retrieving certain values in sequential order. Does HQL support this? THe documentation says so but I get exception as below Query query = session.createQuery(...
Develope001
1

votes
1

answer
2.4k

Views

Hibernate and Oracle DATE column using HQL query

I have an Oracle database with a DATE column. A sample value from this column is 15/12/2014 15:20:15 in the format DD/MM/YYYY HH:MM:SS. I have this column defined as follows in my java Entity class: @Column(name = "SVC_EVENT_END_DTTM", columnDefinition = "timestamp") private Date dateTime; The foll...
conorgriffin
1

votes
2

answer
69

Views

retrieve records between fromdate and todate passing two dates and foreign key value in MYSQL or HQL

retrieve records between fromdate and todate passing two date and foreign key value. i tried this, SELECT* FROM Test where T_ID = 1 and '2015-03-10' BETWEEN FROM_DATE and TO_DATE or '2015-03-18' BETWEEN FROM_DATE and TO_DATE; but it returns foreign key records with another foreign key records betw...
Prasanth A R
1

votes
1

answer
2.6k

Views

Implementing multiple JOINS in HQL

I'm trying to implement an HQL query. I've been able to implement it in SQL - which I'm a little more familiar with. What I keep getting hung up on are the INNER JOINS. The classes are implemented like this... class Item class Component extends Item private Item parentItem; class Assembly extends...
Tim Mitchell
1

votes
1

answer
400

Views

Hibernate entity only one column, no name

I want to map one column, without using a column name. I am using a count entity, and the want to use mulple different queries with the same entity : @Entity public class CountDTO extends Number { @Id // below causes an error in my test, hsql not same syntax @Column(name = 'COUNT') private Long co...
NimChimpsky
1

votes
1

answer
3k

Views

SparkSQL: HQL script in file to be loaded on Python code

Normally, literal query strings suffices for short statements, like these: count = sqlContext.sql("SELECT * FROM db.table").count() However, there are cases where I have a lengthy Hive query script, and that would be too cumbersome to place in Python code. How do I go about referencing an HQL file...
menorah84
1

votes
2

answer
2.8k

Views

Prevent SQL injection with Hibernate

I'm going through Hibernate and I know that you can prevent SQL injection with HQL: String query1 = "from Obj where id = "+ id; String query2 = "from Obj where id = :id"; query1 is unsafe while query2 is safe. How can I achieve safe queries with Criteria? Is this already implemented or do I have to...
5er
1

votes
1

answer
392

Views

HQL and joins - a faster way?

This part of my model is as follows: IQCEntity has many Documents DocumentCategory has many Documents I am using Hibernate for my ORM. Now, please consider the following method: /** * Get all documents in the supplied IQCEntity which are in the * specified DocumentCategory. * @param entity the {@lin...
Memran
1

votes
1

answer
517

Views

Spring, Hibernate : Check for timestamp within expiration time

I am working on a Spring-MVC project with Hibernate and DB as Postgres in which there is a possibility to assign tasks to individual people who are part of a group. Now the tasks have end-time, and I have a scheduler running which every 30 minutes would check if task has around 48hours remaining to...
We are Borg
1

votes
2

answer
1.1k

Views

What is Hive Tablename maximum character limit?

Could not locate a suitable specification about the maximum character limit for a Hive Table. I am developing an ETL process involving hive tables that have specified naming conventions with the format _ and the table names provided are quite larger than 30 byte (normal limit for pl/sql), a straigh...
1

votes
1

answer
847

Views

How to use mod function in HQL

How can we use the mod operation in HQL? Example of MS-SQL: select * from someTable where someColumn%10 = 1
İsmail Yavuz
2

votes
1

answer
1.9k

Views

hql conditional expressions in aggregate functions

Does HQL support conditional expressions in aggregate functions? I would like to do something like this select o.id, count(o), count(o.something is null and o.otherthing = :other) from objects o But I get a MissingTokenException from the Antlr parser. EDIT: By using a subquery it's working, but it'...
simendsjo
2

votes
1

answer
1.3k

Views

Grails dynamic finder where field name contains reserved words

So I have a grails domain class: class Message { Inbox inbox Boolean hasBeenLogicallyDeletedByRecipient ... static belongsTo = [ inbox:Inbox, ... ] static constraints = { hasBeenLogicallyDeletedByRecipient(nullable:false) ... } } I would like to use a dynamic finder as follows: def messages = Messag...
rhu
2

votes
1

answer
3.5k

Views

HQL Casting Error

I'm doing something like this String SQL="From Auction auc where auc.AuctionId IN (:ids)"; String BSQL="Select bid.auction.AuctionId From Bid bid where bid.User.UserId="+UserId; List UserBids=new LinkedList (session.createQuery(BSQL).list()); System.out.println(UserBids.size()); Query query = sessi...
Noor
1

votes
2

answer
2.3k

Views

SQL Server, HQL: How to compare SQL server datetime column field to date

I have following SQL query which i need to make it work in HQL, I tried couple of solutions but none of them work.(Database : SQL server) select t.createdTimeStamp FROM ServiceData t , UserInfo C where C.UserId = t.UserId and CAST(t.createdTimeStamp AS DATE) = '2016-05-30' I tried following in HQL...
Chandra_S
2

votes
1

answer
921

Views

NHibernate query ( hql vs criteria )

I have an hql query string from MyTable table where table.StartTime + table.Duration >= : startTime and table.MyId = : id How can I write this without HQL in NHibernate (using criteria)?
NoviceAndNovice
2

votes
3

answer
4.1k

Views

NHibernate HQL distinct and order by

I've recently upgraded from NHibernate 1.2 to 3.1 in an old code base. I've fixed most problems but I'm stuck on this one. (I can't change from HQL to another access method without lots of changes to the codebase). This wasn't an issue in 1.2, but after the upgrade I'm getting the following problem....
big_tommy_7bb

View additional questions