hql

Hibernate, how to count with condition

末鹿安然 提交于 2019-12-10 10:36:21
问题 I am using oracle and hibernate for mapping. I want to count with a condition in count() function. my code is: select count(case when st.averageMark < su.gradePass then 1 else 0 end) from Study st join st.subject su where st.acaYear in (2009) and st.semester = 4 and su.idSeq = 1330 group by st.acaYear the code return me nothing. I used sum instead of count it returned a result but it is wrong, the result is bigger than I suppose it to be. thank in advance. 回答1: I just solved the problem with

org.hibernate.MappingException: entity class not found ( using qualified class name does not work)

故事扮演 提交于 2019-12-10 09:43:50
问题 I'm trying to run a simple SELECT FROM table ( I have also tried SELECT FROM package.Class )query but I keep getting this error : org.hibernate.MappingException: entity class not found: demo.Agents at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:125) at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:191) at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67) at org.hibernate.tuple.entity.EntityMetamodel.<init>

Hibernate 3.6: registerFunction in SQL dialect not working

a 夏天 提交于 2019-12-10 04:22:50
问题 I´m giving up and ask the community ... In my project, I´m using Hibernate 3.6.4.Final and a custom sql dialect: public class ServiceAppMySQL5InnoDBDialect extends MySQL5InnoDBDialect { public ServiceAppMySQL5InnoDBDialect() { super(); registerFunction("bitwise_and", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "(?1 & ?2)")); registerFunction("hasflags", new SQLFunctionTemplate(StandardBasicTypes.BOOLEAN, "?1 & ?2 = ?2")); } } Using the hasflags method in a HQL query fails. Here is the

nhibernate hql with named parameter

人走茶凉 提交于 2019-12-10 03:00:44
问题 I have implemented a search function using Castel Active Record. I thought the code is simple enough but I kept getting NHibernate.QueryParameterException : could not locate named parameter [searchKeyWords] errors. Can someone tell me what went wrong? Thanks a million. public List<Seller> GetSellersWithEmail(string searchKeyWords) { if (string.IsNullOrEmpty(searchKeyWords)) { return new List<Seller>(); } string hql = @"select distinct s from Seller s where s.Deleted = false and ( s.Email like

Inner join using HQL

那年仲夏 提交于 2019-12-10 02:42:04
问题 I am trying to inner join two tables on one column. From DB side, there's no mapping as it's something I don't want to discuss. I want to execute HQL query using INNER JOIN and retrieve ROLE objects/results. Here's my hql so far session.createQuery("from ROLE as role INNER JOIN INVOLVEMENT as involvement ON role.id = involvement.roleid WHERE involvement.id = X").list(); I see ON is not available on HQL. how do i explicitly tell Hibernate to JOIN on this column only. I tried below one too

How to left join unrelated entities?

蓝咒 提交于 2019-12-10 02:30:48
问题 When i try to run a query like this: QA A = QA.a; QB B = QB.b; ... from(A) .leftJoin(B).with(B.name.eq(A.nameSomething)); (A and B entities are not related) I'm always getting this error: Caused by: org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! I would like to be able to left join unrelated entities using querydsl. Is it possible at all? Or the only way is to write a native Oracle query? 回答1: Joining unrelated entities is not possible with Querydsl JPA. Querydsl JPA uses

Get row count from all tables in hive

情到浓时终转凉″ 提交于 2019-12-09 17:39:12
问题 How can I get row count from all tables using hive. I am interested in database name, table name and row count 回答1: You will need to do a select count(*) from table for all tables. To automate this, you can make a small bash script and some bash commands. First run $hive -e 'show tables' | tee tables.txt This stores all tables in the database in a text file tables.txt Create a bash file (count_tables.sh) with the following contents. while read line do echo "$line " eval "hive -e 'select count

How to set limit for a hibernate query

安稳与你 提交于 2019-12-09 16:07:50
问题 How can I set a limit to this hql query? When I add the limit keyword in the query, an error is thrown. @Query("from voucher v where v.voucherType.typeDescription = :typeDescription and v.denomination = :denomination") public List<Voucher> findByVoucherTypeAndDenomination(@Param("typeDescription") String typeDescription,@Param("denomination") BigDecimal denomination); 回答1: When you call your query add the following: .setFirstResult(firstResult).setMaxResults(limit); UPDATE Docs: http://docs

How to left join fetch multiple children in Hibernate?

偶尔善良 提交于 2019-12-09 14:10:47
问题 I'm working with hibernate and I'm having troubles creating an hql query that fetches all the children of my object. For example: The Object User has a list of Cars and a list of Friends. To get a user with his cars I would use following query: from User u left join fetch u.cars where u.id = ? This works fine, so I thought it would be easy to get a user with his cars and with his friends with following query: from User u left join fetch u.cars left join fetch u.friends where u.id = ? But this

Data visualisation tools availble on hive hadoop

霸气de小男生 提交于 2019-12-09 13:30:45
问题 Please suggest some visualisation tools which can work on Hive-Hadoop. The only thing is, it should accept Hive . 回答1: It depends what type of data analysis and visualization you have in mind. If you intend to use a proprietary tool, then Tableau is one of among many other options. If you prefer tools that are open source (free and multi-platform), then you should consider using: HUE Beeswax HBase Pig Google Chart ColorBrewer R Qt/QML Octave OpenGL Hive will not block you from using any of