hql

Hibernate AliasToBean with Collection

╄→尐↘猪︶ㄣ 提交于 2020-01-12 10:02:52
问题 I have a bi-directional one-to-many relationship defined between Parent and Child classes. I'm looking to execute a query such that I can return a single parent, and a subset of its children in a bean. public class Parent { private int id; private Set<Child> children = new HashSet<Child>(0); // other fields + getters and setters } public class Child { private Parent parent; private int age; // other fields + getters and setters } The output I'm looking to achieve is: public class

How to search in multiple columns using one like operator in HQL (hibernate sql)

蹲街弑〆低调 提交于 2020-01-11 11:46:27
问题 Hope someone can help me with this HQL query. I'm using: Query query = session.createQuery(sql); where the sql is: select distinct c.id from EstateConsumer as c where c.clientId = ? and (c.vehicleReg1 or c.vehicleReg2) like ? but is getting the following exception: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: or near line 1, column 121 So how can you use the "OR" syntax by using one "like"? The following however works: select distinct c.id from EstateConsumer as c where c

Dropping a range of partitions in HIVE

折月煮酒 提交于 2020-01-10 19:34:07
问题 I have a Hive (ver 0.11.0) table partitioned by column date, of type string. I want to know if there exists a way in Hive by which I can drop partitions for a range of dates (say from 'date1' to 'date2'). I have tried the following (SQL type) queries, but they don't seem to be syntactically correct: ALTER TABLE myTable DROP IF EXISTS PARTITION (date>='date1' and date<='date2'); ALTER TABLE myTable DROP IF EXISTS PARTITION (date>='date1' && date<='date2'); ALTER TABLE myTable DROP IF EXISTS

HQL - row identifier for pagination

心已入冬 提交于 2020-01-09 03:20:46
问题 Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM? I would like to implement pagination with HQL but I am not able to use .setMaxResult() or .setFirstResult() because I don't work with the session object directly and therefore don't use the Query object but simply create my query as a string and use the .find() method. I tried using LIMIT and OFFSET in my query, but HQL seems to be ignoring these keywords and is returning the whole result to me no matter what. I'm

HQL - row identifier for pagination

旧街凉风 提交于 2020-01-09 03:20:20
问题 Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM? I would like to implement pagination with HQL but I am not able to use .setMaxResult() or .setFirstResult() because I don't work with the session object directly and therefore don't use the Query object but simply create my query as a string and use the .find() method. I tried using LIMIT and OFFSET in my query, but HQL seems to be ignoring these keywords and is returning the whole result to me no matter what. I'm

Not converting yearweek function with QueryDSL

烈酒焚心 提交于 2020-01-07 08:35:13
问题 I would like to use the yearweek() function of QueryDSL, which is supported by QueryDSL. This function generates the query select year(table1.timestamp)*100 + week(table1.timestamp) as col_0_0_ [...] . This does, however, not return a correct result on year endings. I've already opened a bug report for this issue. I would rather use the built-in SQL yearweek() function, which is directly supported by e.g. MariaDB. Is there a way of using the SQL function YEARWEEK(timestamp) with QueryDSL? Or

JPQL: why 'group by' does not work properly

ε祈祈猫儿з 提交于 2020-01-07 03:45:07
问题 Executing JPQL using hibernate 4.2.5: select c from Chargeback as cc join cc.customer as c group by c order by max(cc.created) Usecase: show customers with the latest chargbacks. produces org.hibernate.exception.SQLGrammarException: could not extract ResultSet When using select c.id from Chargeback as cc join cc.customer as c group by c order by max(cc.created) it will work. When using select c from Chargeback as cc join cc.customer as c group by c.id, c......all columns order by max(cc

createQuery not working but createNativeQuery works

耗尽温柔 提交于 2020-01-06 18:12:29
问题 guy, I have a very strange problem. I am setting up some endpoints in my application and I have an endpoints like this: @Path("/ioconfiguration") public class IOConfigurationEndPoint { @EJB private static IOConfigurationDAO ioConfigurationDAO; @GET @Produces(MediaType.APPLICATION_JSON) public Response getAllIoConfigurations() { ioConfigurationDAO = new IOConfigurationDAO(); ioConfigurationDAO.init(); List<IOConfiguration> list = ioConfigurationDAO.findAllIOConfiguration(); ioConfigurationDAO

JOINs with conditon in HQL query?

China☆狼群 提交于 2020-01-06 14:58:18
问题 How can i write to HQL Query? This is My Original scenario I have two hbm files ADVMAgencyMaster.hbm.xml,ADVRoheader.hbm.xml corresponding pojo classes are ADVMAgencyMaster.java,ADVroheader.java. <hibernate-mapping> <class name="com.adv.hibernatebean.ADVMAgencyMaster" table="ADVMAGENCYMASTER" catalog="MEDIAERP"> <id name="mamaid" type="java.lang.String"> <column name="MAMAID" length="10" /> <generator class="assigned"></generator> </id> <property name="mamaname" type="java.lang.String">

Hive : Concat a map

感情迁移 提交于 2020-01-06 13:50:30
问题 I have a small trouble into Hive, when I try to concatenate map Assume that I've something like that : var 1 | var 2 x | map(key1:value1) x | map(key2:value2) x | map(key3:value3) y | map(key4:value4) What I'am trying to get, It's something like that var 1 | var 2 x | map(key1:value1 ; key2:value2; key3:value3) y | map(key4,value4) Something like a map concatenation. How can I proceed whith Hive ? 回答1: Use this Query... select var1,collect_set(CONCAT_WS(',',map_keys(var2),map_values(var2)))