hql

HQL unexpected AST node: {vector}

眉间皱痕 提交于 2019-12-08 16:14:22
问题 I'm trying to write an HQL query to grab a list of users that belong to a particular organisation, or any franchisee from a list of franchisees, however hibernate isn't able to parse it. I can't figure out why. Here is the HQL: from User u where (u.parentOrganisation = :topLevelOrganisation or u.parentOrganisation in :franchisees) and u.parentOrganisation.deleted = false and u.active = true This is the error that hibernate spits out: unexpected AST node: {vector} [from com.myapp.User u where

Hibernate @Formula doesn't include Schema

只谈情不闲聊 提交于 2019-12-08 16:01:16
问题 I have an entity with a property @Formula like this: @Entity @Table(name = "areasAuxiliar") public final class AreaAuxiliar implements Serializable { @Id @Column(name = "idArea") private Integer idArea; @Formula("RUTAAREA(idArea)") private String ruta; when I configure my hibernate to point to an Oracle DB I have no problem, BUT, when I switch to an SQLServer, hibernate is not including the shema and the query fails, the query generated for hibernate looks like this: select areaauxili4_

HQL unexpected AST node: :

心已入冬 提交于 2019-12-08 15:27:44
问题 My code is failing to inject the below repository. Based on the stack trace, it seems my HQL syntax is invalid, but I'm not sure what I've done wrong. @Repository public interface JobSetRepository extends JpaRepository<JobSetEntity, Integer> { @Modifying @Transactional @Query("UPDATE JobSetEntity SET workstation = :workstation, workflowProcess = :workstation.workflowProcess WHERE id = :jobSet.id") public Boolean updateWorkstation(@Param("jobSet") JobSetEntity jobSet, @Param("workstation")

hibernate之HQL

回眸只為那壹抹淺笑 提交于 2019-12-08 14:18:27
1.什么是HQL? HQL是Hibernate Query Language(Hibernate 查询语言)的缩写,提供更加丰富灵活、更为强大的查询能力;HQL更接近SQL语句查询语法。Hibernate 查询语言(HQL)是一种面向对象的查询语言,类似于 SQL,但不是去对表和列进行操作,而是面向对象和它们的属性。 HQL 查询被 Hibernate 翻译为传统的 SQL 查询从而对数据库进行操作。 2.HQL查询的步骤 执行HQL查询的步骤: 1、获得HibernateSession对象 2、编写HQL语句 3、调用Session的createQuery方法创建查询对象 4、如果HQL语句包含参数,则调用Query的setXxx方法为参数赋值 5、调用Query对象的list等方法返回查询结果。 3.hibernate查询操作 Query 接口让你方便地对数据库及持久对象进行查询,它可以有两种表达方式: HQL 语言或本地数据库的 SQL 语句。 Query 经常被用来绑定查询参数、限制查询记录数量,并最终执行查询操作。 通过 Query 主要完成查询操作 . 我们通过 Query 可以执行 hql 语句 . Query query=Session.createQuery(hql); 下面这个可以执行 sql 语句 SQLQuery sqlQuery=Session

Getting error on selecting a value from a drop down select

♀尐吖头ヾ 提交于 2019-12-08 12:39:18
问题 I want to fetch a selected value from a drop down 'select' list of 'form' in a jsp page into a variable defined in the action class of the form, where 'select' drop down list is itself fetched dynamically from a column 'name' of database table 'Category' with the list 'categoryList' which is defined in some another action class. After fetching the selected value (that is a name of Category) i want to fetch the primary key 'cid' of the table 'Category'. columns of Category are : id, name After

special characters in HQL

霸气de小男生 提交于 2019-12-08 11:22:27
问题 hi i'm trying to get from a mySql DB a query using Hibernates HQL * public String getDetailsByUserAndFullPath(String user,String fullpath) { String temp2 = "%" + user + "%"; String temp3 = "%" + fullpath + "%"; // Query query = Query query_bd = session .createQuery("from Files files where user like ? and full_path like ? escape '\'"); query_bd.setString(0, temp2); query_bd.setText(1, temp3); List<Files> list = query_bd.list(); the problem is the fullpath contains \ such as c:\temp\example

SSM Excel表格导出导入

≡放荡痞女 提交于 2019-12-08 08:23:35
项目中经常要用到Excel表格的导出导入。故此,写了一个测试。现在奉上源码。 项目的目录结构: 目录结构截图 页面展示截图: 导出截图 导入截图成功插入数据库 现在给出全部源码: 一: PoiService.java package com.bank.service; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss

Querying an Oracle Date field using a string in NHibernate HQL

北城以北 提交于 2019-12-08 08:07:57
问题 I'm trying to query a .NET DateTime property and compare it with a date string like so: SELECT cat FROM mydll.cats AS cat WHERE cat.BirthDay > '1999-02-20' When I'm trying to search by a date string (without the SetDate function) The query won't run saying I canno't compare a String to a Date . Is there a way or a certain format I can use to compare my date with a simple string (Maybe something like the ToDate function in Oracle SQL..) *I need to separate the HQL string from the NHibernate

Using HQL to query on a Map's Values

南笙酒味 提交于 2019-12-08 07:37:45
问题 Let's say I have a map (call it myClass.mapElem<Object, Object> ) like so: Key Val A X B Y C X I want to write HQL that can query the Values such that I can get back all instances of myClass where mapElem's value is 'X' (where 'X' is a fully populated object-- I just don't want to go through each element and say x.e1 = mapElem.e1 and x.e2=... etc). I know I can do this for the keys by using where ? in index(myClass.mapElem) , I just need the corresponding statement for querying the values!

Number of days between two given dates

杀马特。学长 韩版系。学妹 提交于 2019-12-08 06:50:53
问题 How do I calculate number of days between the to dates strictly using HQL alone. supposing Current_Date and Expiry_Date are two dates fetched from database. I want to calculate days between Current_Date and Expiry_Date . Also, How will I handle, if any of the value is null ? 回答1: DECLARE @startdate datetime2 = '2013-12-05 12:10:09.3312722'; DECLARE @enddate datetime2 = '2013-12-04 12:10:09.3312722'; SELECT DATEDIFF(day, isnull(@startdate,GetDate()), isnull(@enddate,GetDate())); 回答2: I figured