hql

How to select the sum of multiple count() selections in JPQL

穿精又带淫゛_ 提交于 2019-12-23 15:59:58
问题 What's the equivalent JQPL statement of the following SQL statement: SELECT (SELECT COUNT(*) FROM foo) + (SELECT COUNT(*) FROM bar) 回答1: You can use the query you stated above along with EntityManager's createNativeQuery function see example class below: package facades; import javax.ejb.LocalBean; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; @Stateless @LocalBean public class CustomFacade {

Annotation @Basic to transient variables

橙三吉。 提交于 2019-12-23 09:40:42
问题 I am having a POJO class which consists of: - persistent properties, - transient properties. While writing HQL I considered both: persistent and transient properties. I.e. HQL like select persistent_properties,transient_prop from Pojo_classname is it correct? Can I write @Basic annotation to transient variables? 回答1: No, it's not correct. A HQL query translates to SQL. An @Transient property is not in the database, so the SQL query won't be able to query over this property. @Basic and

HQL vs. SQL / Hibernate netbeans HQL editor

萝らか妹 提交于 2019-12-23 09:29:06
问题 I am teaching my self hibernate, and am quite confused of why i can not just write simple SQL queries. I find it rather more confusing to use than plain SQL (what I am used to) PLUS: The NetBeans HQL editor I found pretty annoying, It is harder for me to produce a right query in HQL, then in SQL, and why does the shown SQL differ from actual SQL statements ? So why use it ? - As it is known that hibernate is very resource extensive, and I believe that hibernate is the reason for our app to

Join Fetch: "query specified join fetching, but the owner of the fetched association was

折月煮酒 提交于 2019-12-23 07:36:58
问题 I have the following Model Activity with the language-depending property Title . The language-dependency is defined with two additional entities Translation (Title is of this type, many-to-one) and TranslationValue (one-to-many). If I write the following hql: from Activity act join fetch act.Title join fetch act.Title.TranslationValuesSet This works fine so far. But as soon as I add act into the select-statement, I've got a problem with the join of TranslationValuesSet: select act from

“Not supported for DML operations” with simple UPDATE query

谁都会走 提交于 2019-12-23 06:44:08
问题 I'm getting the error Not supported for DML operations when I use the following HQL... @Query("UPDATE WorkstationEntity w SET w.lastActivity = :timestamp WHERE w.uuid = :uuid") void updateLastActivity(@Param("uuid") String uuid, @Param("timestamp") Timestamp timestamp); What could be causing the issue? It doesn't seem to be a common error given the few results I've found in Google. 回答1: Check the post hibernate hql ERROR: Not supported for DML operations in the hibernate users forum. Most

CRUD operations in Hive

橙三吉。 提交于 2019-12-23 05:01:50
问题 I'm trying to do CRUD operations in Hive and able to successfully run insert query however when I tried to run update and delete getting the below exception. FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations. List of the queries I ran CREATE TABLE students (name VARCHAR(64), age INT, gpa DECIMAL(3, 2)) CLUSTERED BY (age) INTO 2 BUCKETS STORED AS ORC; INSERT INTO TABLE students VALUES ('fred flintstone', 35,

CRUD operations in Hive

二次信任 提交于 2019-12-23 05:01:32
问题 I'm trying to do CRUD operations in Hive and able to successfully run insert query however when I tried to run update and delete getting the below exception. FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations. List of the queries I ran CREATE TABLE students (name VARCHAR(64), age INT, gpa DECIMAL(3, 2)) CLUSTERED BY (age) INTO 2 BUCKETS STORED AS ORC; INSERT INTO TABLE students VALUES ('fred flintstone', 35,

Hql join and group by problem

时光总嘲笑我的痴心妄想 提交于 2019-12-23 04:44:06
问题 I am trying to make a query in hql. I have these beans: Bean1 @Entity @Table(name = "bean1") public class Bean1 { ... private List<Bean2> bean2; ... @ManyToMany( cascade={CascadeType.ALL}, fetch=FetchType.LAZY) @JoinTable( name="bean1_bean2", joinColumns=@JoinColumn(name="bean1_id"), inverseJoinColumns=@JoinColumn(name="bean2_id") ) public List<Bean2> getBean2() { return bean2; } public void setTags(List<Bean2> bean2) { this.bean2 = bean2; } ... } Bean2 @Entity @Table(name = "bean2") public

HQL Select where Row appears more than once

冷暖自知 提交于 2019-12-23 04:43:57
问题 I am attempting to bring back rows where two column values appear more than once. Note, this is not a priority. For example, in the table.. ID Name Country 1 Dave UK 2 Jim UK 3 Dave UK 4 Dave US 5 Jim US Then it would return row 1 and row 3, but none of the others. This is because the combination of "Dave" and "UK" only appears in those rows. I am struggling to implement a HQL query to obtain this. To get things going, I tried to group on just name: from Runner r group by r.name having count

JPQL / HQL - Limit items for list of children

一世执手 提交于 2019-12-23 03:19:08
问题 I have following entity relationship: @Entity public class Parent { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(columnDefinition = "serial") private Long id; @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY) private List<Child> children; } and Child entity: @Entity public class Child { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(columnDefinition = "serial") private Long id; @ManyToOne(optional = false, fetch = FetchType.LAZY) private Parent parent