hql

Is it correct to use to_date() in hibernate if date is stored as string like (132011) in Database?

≡放荡痞女 提交于 2019-12-25 03:09:26
问题 I have a table "Products(id, name, productionDate)" in Oracle database. "date" column is defined as String and it has value like "131120" (1st two digits for year, 2nd two digits for year & final two digits for date). I need a sorted output based on date using Hibernate. SQL query to do this is like the following: select * from products order by to_date(productionDate, 'YYMMDD') desc; This sql query is fine when I try from command prompt. But when I tried to use this query using Hibernate, I

Fill property of DTO with SubQuery in NHibernate Query

痞子三分冷 提交于 2019-12-25 02:55:10
问题 I have a DTO object like this: public class TreeViewDTO { public string Value { get; set; } public string Text { get; set; } public bool HasChildren { get; set; } } and my entity mapped with Nhibernate is: public class Entity { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Entity Parent { get; set; } /* other properties */ } I would like to know, how can I get a List of my DTOs and fill the HasChildren property using a count method or a subquery

What is the correct Hibernate Query syntax for a join between two classes / tables?

痞子三分冷 提交于 2019-12-25 02:29:23
问题 I have been at this for hours without success. For everything I try from other incidents logged here or examples elsewhere, the HQL syntax always seems to be wrong in my method: Session session = sessionFactory.openSession(); try { Query query = session.createQuery("select p from Person p join p.books where p.personId = :personId").setParameter("personId", personId); List<Person> persons = query.list(); Person person = persons.get(0); Hibernate.initialize(person.getBooks()); return person; }

Update with Join hibernate (HQL)

喜夏-厌秋 提交于 2019-12-25 02:01:22
问题 I'm on trouble with an hql problem. I would like to write a query, that updates an attribut, and that's based on a value on another table. This is my example, I have those two tables : Client and Widhdrawal. Client : idClient, name ... Widhdrawal : idWidh, cost, and the idClient (foreign key) Now if i would update the client, under the condition of (idClient = 5 for example), i can't. I tried this, but in vain : String hql = "UPDATE Widhdrawal W set W.cost = :salary " + "where W.Client.id

Hibernate HQL delete query

喜你入骨 提交于 2019-12-25 01:55:32
问题 Im looking for information but I didnt find how. I have two tables: Remesas |codigo_prod| nombre |codigo_proveedor| ----------------------------------------- | 1001 | product1 | EST | | 1002 | product2 | ASM | - Proveedores |codigo_proveedor| mail | ---------------------------------- | EST | pro@mail.com | | ASM | pro2@mail.com | | DAM | pro3@mail.com | I have to delete from Proveedores the row that dont have codigo_proveedor on Remesas in this case delete DAM that its not on Remesas. Thank

HIVE CREATE TABLE sematicException 0:0

时光毁灭记忆、已成空白 提交于 2019-12-24 19:35:43
问题 HI, all : i am newbie at hive, i got this error when i was creating a table using "select from " syntax, my input is as following: `hive>create table longyuan_web.tmp_recent_week_data_cookies as select u from longyuan_web.ods_mbw_user_pv where dt>='2018-07-19' and dt<='2018-07-25'and platform='31' and u is not null and length(u)>=32 and os='ios' group by u` i get this error: FAILED: SemanticException 0:0 Error creating temporary folder on: hdfs://hadoop-bd-ns01/hive/warehouse/longyuan_web.db.

NHibernate and MySql Keywords

吃可爱长大的小学妹 提交于 2019-12-24 19:29:26
问题 Why Nibernate HQL can not handle the following query: from Deal D where (D.ApprovalDate + INTERVAL 1 Year) < current_timestamp() < (D.RenewalDate + INTERVAL -1 Year) knowing that INTERVAL and YEAR are keywords in MySQL, so this is kind of mixing Sql within Hql (unless Hql can handle date functions like so and I don't know) . The dialect is MySQLDialect Its perfectly valid to execute this query SELECT '2005-01-01' + INTERVAL 1 Year; 回答1: You can pass the Sql directly in the query using

NHibernate IQueryOver.ToRowCountQuery() equivalent when Using HQL IQuery

怎甘沉沦 提交于 2019-12-24 19:12:05
问题 I'm trying to implement paging within my project. When using NHibernate's IQueryOver syntax as shown below things are working as expected. public PagedResult<T> ExecutePagedQuery(IQueryOver<T,T> query) { SetPaging(query); var results = query.Future<T>(); var count = query.ToRowCountQuery().FutureValue<int>(); return new PagedResult<T>() { TotalItemCount = count.Value, PageOfResults = results.ToList() }; } protected virtual void SetPaging(IQueryOver<T, T> query) { var maxResults = PageSize;

how to escape colon in HQL

霸气de小男生 提交于 2019-12-24 18:05:40
问题 I have condition part of my query as follows: ... where foo.bar like '%:%' the query would execute but with no result. I think it's because of the colon since it is a reserved char in HQL. So how can I escape it without sending the : as a parameter to my query. I have already used '%\:%' and '%\\:%' with no success. 回答1: I found a solution: q=q.replaceAll(":","'||unistr('\\003A')||'"); 来源: https://stackoverflow.com/questions/18614960/how-to-escape-colon-in-hql

Oracle char type issue in Hibernate HQL query

余生长醉 提交于 2019-12-24 13:30:01
问题 I have Oracle table, which contains char type columns. In my Entity class i mapped oracle char type to java string type. Here is the code for my Entity class. @Entity @Table(name="ORG") public class Organization { private String serviceName; private String orgAcct; //Some other properties goes here... @Column(name="ORG_ACCT", nullable=false, length=16) public String getOrgAcct() { return this.orgAcct; } public void setOrgAcct(String orgAcct) { this.orgAcct = orgAcct; } @Column(name="SERVICE