hql

Native query is faster than HQL/Criteria query in Hibernate

时间秒杀一切 提交于 2019-12-13 21:26:52
问题 I have a table which has partition on daily basis. When I used query through HQL/Criteria, it took 240 sec to get the results in Hibernate. The same query(native query created by Hibernate) took 2sec when I used directly or through JDBC connection. Note: The native query has taken less than 2 sec from postgres db(direct firing). Please reply where might be the problem Here is the Entity with Named Query: import java.io.Serializable; import java.sql.Timestamp; import javax.persistence.Column;

Escape quote in HQL query

佐手、 提交于 2019-12-13 17:17:34
问题 I'm developping an application with spring mvc and hibernate, i have a problem in my hql query when i want to select an object from the database by his name. Because the name contain a quote (ingénieur d'étude) String hql = "From Intervenant I Where I.profil like '"+profil+"'"; i had this exception : org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.QueryException: expecting ''', found '<EOF>' [From com.model.Intervenant I Where

How to transform this native SQL query to an HQL

∥☆過路亽.° 提交于 2019-12-13 16:10:27
问题 So I have this long complexe Native SQLQuery : string hql = @"SELECT * FROM (SELECT a.*, rownum r__ FROM (select f2.filmid, f2.realisateurid, f2.titre, f2.annesortie, f2.langue, f2.duree, f2.resume, f2.poster, f2.qtytotal, f2.qtydisponible from film f2 where f2.filmid in ( select distinct f.filmid from film f, filmpays fp, pays p, filmgenre fg, genre g, informationpersonnel director, role r, informationpersonnel actor where f.filmid = fp.filmid and fp.paysid = p.paysid and f.filmid = fg

Multi Join in a single SQL query

允我心安 提交于 2019-12-13 15:40:23
问题 Below is the data in TestingTable1 sorted by date in descending order always BUYER_ID | ITEM_ID | CREATED_TIME ----------+-----------------+---------------------- 1345653 110909316904 2012-07-09 21:29:06 1345653 151851771618 2012-07-09 19:57:33 1345653 221065796761 2012-07-09 19:31:48 1345653 400307563710 2012-07-09 18:57:33 And if this is the below data in TestingTable2 sorted by date in descending order always USER_ID | PRODUCT_ID | LAST_TIME ---------+----------------+---------------------

Does anyone know how to translate LINQ Expression to NHibernate HQL statement?

六眼飞鱼酱① 提交于 2019-12-13 12:21:37
问题 Does anyone know of an existing solution to translate a LINQ Expression to HQL statement? Thanks in advance to all the good samaritans out there. P.S. We already use Linq to NHibernate. However, it only works for select statements, whereas HQL is good for other statement kinds, like delete. So, Linq to NHibernate is not the answer. 回答1: Linq to nhibernate has just been released . Does that help? 回答2: I had the exact same need: I needed to delete using a LINQ expression, but NHibernate only

Query conversion - Sql to Hql

雨燕双飞 提交于 2019-12-13 07:24:13
问题 I have this query and I need to convert it in hql but I am little confused, don't know how to write condition presented in 'where' clause in hql. SELECT message FROM p_message WHERE message_id=( SELECT a.scene FROM p_config a INNER JOIN p_rec_type b ON a.email_id=b.email_id AND rec_type=2 WHERE a.email_type=1 ) what is hql equivalent of this sql query? 回答1: Please find below the HQL query: Assuming that p_message & p_config are domain object names & others are attributes mapping to column.

SQL WHERE Help: how do i pull data from multiple rows in one single query?

主宰稳场 提交于 2019-12-13 07:18:07
问题 I am not sure if this is supposed to use a subquery, or multiple temp tables...but any assistance would be great! i am trying to do the following in one query pull. I want to pull, say, all rows where a User has Color=blue and Color=red. I am interested in pulling these multiple rows to determine which users CHANGED their Color from blue to red, or from red to blue. The general query i have now is this. What is wrong and how can i improve it? thank you! Does this return Zero results because I

Grails 3 - return list in query result from HQL query

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 07:00:55
问题 I have a domain object: class Business { String name List subUnits static hasMany = [ subUnits : SubUnit, ] } I want to get name and subUnits using HQL, but I get an error Exception: org.springframework.orm.hibernate4.HibernateQueryException: not an entity when using: List businesses = Business.executeQuery("select business.name, business.subUnits from Business as business") Is there a way I can get subUnits returned in the result query result as a List using HQL? When I use a left join, the

Unable to convert SQL which is meant for greatest N per group to HQL

主宰稳场 提交于 2019-12-13 05:49:26
问题 I have two tables in Oracle namely product and product_image . As the names imply they have a one-to-many relationship from product to product_image. The product entity: @Entity @Table(name = "PRODUCT", catalog = "", schema = "WAGAFASHIONDB") public class Product implements java.io.Serializable { private static final long serialVersionUID = 1L; @Id @Basic(optional = false) @Column(name = "PROD_ID", nullable = false, precision = 35, scale = 0) @SequenceGenerator(name = "productIdSequence",

Hive jobs occurs mapreduce error : Call From hmaster/127.0.0.1 to localhost:44849 failed on connection exception

我们两清 提交于 2019-12-13 05:19:38
问题 When I run in hive command line: hive > select count(*) from alogs; On the terminal, it shows the following : Total jobs = 1 Launching Job 1 out of 1 Number of reduce tasks determined at compile time: 1 In order to change the average load for a reducer (in bytes): set hive.exec.reducers.bytes.per.reducer=<number> In order to limit the maximum number of reducers: set hive.exec.reducers.max=<number> In order to set a constant number of reducers: set mapreduce.job.reduces=<number> Starting Job =