1.from子句
from Person
表明从Person持久化类中选出全部的实例。
推荐:from Person as p
2.select子句
select p.name from Person as p
select p.name.firstName from Person as p
select new list(p.name, p.address) from Person as p
select new ClassTest(p.name, p.address) from Person as p (有前提)
select p.name as personName from Person as p
select new map(p.name as personName) from Person as p (与new map()结合更普遍)
3.聚集函数
avg,count,max,min,sum
select count(*) from Person
select max(p.age) from Person as p
select p.name || "" || p.address from Person as p
4.多态查询
from Person as p
from java.lang.Object o
from Named as n
5.where子句
from Person where name like "tom%"
from Person as p where p.name like "tom%"
from Cat cat where cat.mate.name like "kit%"
select * from cat_table as table1 cat_table as table2 where table1.mate =
table2.id and table1.name like "kit%"
from Foo foo where foo.bar.baz.customer.address.city like "fuzhou%"
from Cat cat, Cat rival where cat.mate = rival.mate
select cat, mate
from Cat cat, Cat mate
where cat.mate = mate
from Cat as cat where cat.id = 123
from Cat as cat where cat.mate.id = 69
from Person as person
where person.id.country = 'AU'
and person.id.medicareNumber = 123456
from Account as account
where account.owner.id.country = 'AU'
and account.owner.id.medicareNumber = 123456
from Cat cat where cat.class = DomesticCat
from Account as a where a.person.name.firstName like "dd%" // 正确
from Account as a where a.person.name like "dd%" // 错误
6.表达式
from DomesticCat cat where cat.name between 'A' and 'B'
from DomesticCat cat where cat.name in ('Foo', 'Bar', 'Baz')
from DomesticCat cat where cat.name not between 'A' and 'B'
from DomesticCat cat where cat.name not in ('Foo', 'Bar', 'Baz')
from DomesticCat cat where cat.name is null
from Person as p where p.address is not null
<property name="hibernate.query.substitutions">true 1, false 0</property>
from Cat cat where cat.alive = true
from Cat cat where cat.kittens.size > 0
from Cat cat where size(cat.kittens) > 0
from Calendar cal where maxelement(cal.holidays) > current date
from Order order where maxindex(order.items) > 100
from Order order where minelement(order.items) > 10000
//操作集合元素
select mother from Cat as mother, Cat as kit
where kit in elements(foo.kittens)
//p的name属性等于集合中某个元素的name属性
select p from NameList list, Person p
where p.name = some elements(list.names)
//操作集合元素
from Cat cat where exists elements(cat.kittens)
from Player p where 3 > all elements(p.scores)
from Show show where 'fizard' in indices(show.acts)
//items是有序集合属性,items[0]代表第一个元素
from Order order where order.items[0].id = 1234
//holidays是map集合属性,holidays[national day]是代表其中第一个元素
select person from Person person, Calendar calendar
where calendar.holidays['national day'] = person.birthDay
and person.nationality.calendar = calendar
//下面同时使用list集合和map集合属性
select item from Item item, Order order
where order.items[order.deliveredItemIndices[0]] = item and order.id = 11
select item from Item item, Order order
where order.items[maxindex(order.items)] = item and order.id = 11
select item from Item item, Order order
where order.items[size(order.items) - 1] = item
select cust
from Product prod,
Store store
inner join store.customers cust
where prod.name = 'widget'
and store.location.name in ['Melbourne', 'Sydney']
and prod = all elements(cust.currentOrder.lineItems)
SELECT cust.name, cust.address, cust.phone, cust.id, cust.current_order
FROM customers cust,
stores store,
locations loc,
store_customers sc,
product prod
WHERE prod.name = 'widget'
AND store.loc_id = loc.id
AND loc.name IN ('Melbourne', 'Sydney')
AND sc.store_id = store.id
AND sc.cust_id = cust.id
AND prod.id = ALL(
SELECT item.prod_id
FROM line_items item, orders o
WHERE item.order_id = o.id
AND cust.current_order = o.id
)
7.order by子句
from Person as p
order by p.name, p.age
from Person as p
order by p.name asc, p.age desc
8.group by子句
select cat.color, sum(cat.weight), count(cat)
from Cat cat
group by cat.color
//select后出现的id处出现在group by之后,而name属性则出现在聚集函数中
select foo.id, avg(name), max(name)
from Foo foo join foo.names name
group by foo.id
select cat.color, sum(cat.weight), count(cat)
from Cat cat
group by cat.color
having cat.color in (eg.Color.TABBY, eg.Color.BLACK)
select cat
from Cat cat
join cat.kittens kitten
group by cat
having avg(kitten.weight) > 100
order by count(kitten) asc, sum(kitten.weight) desc
9.子查询
from Cat as fatcat
where fatcat.weight > (select avg(cat.weight) from DomesticCat cat)
from Cat as cat
where not (cat.name, cat.color) in (
select cat.name, cat.color from DomesticCat cat
)
10.fetch关键字
from Person as p join p.scores
from Document fetch all properties order by name
from Document doc fetch all properties where lower(doc.name) like '%cat%'
11.命名查询
<!--定义命名查询-->
<query name="myNamedQuery">
<!--此处确定命名查询的HQL语句-->
from Person as p where p.age > ?
</query>
调用命名查询的示例代码如下:
private void findByNamedQuery() throws Exception {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
System.out.println("执行命名查询");
//调用命名查询
List pl = sess.getNamedQuery("myNamedQuery")
//为参数赋值
.setInteger(0, 20)
//返回全部结果
.list();
//遍历结果集
for (Integer pit = pl.iterator(); pit.hasNext(); )
{
Person p = (Person)pit.next();
System.out.println(p.getName());
}
tx.commit();
HibernateUtil.closeSession();
}
相关推荐
常用的hql语句用法解析
解析内容清晰简单,让你对hql语句半天就可以掌握!!
HQL QBC
一、HQL查询的from子句 from是最简单的语句,也是最基本的HQL语句。from关键字后紧跟持久化类的类名。 例如: from Person 表明从Person持久化类中选出全部的实例 推荐为Person持久化类的每个实例起别名,例如: from Person as p p作为Person的实例的别名,因此也应该遵守Java的命名规则:第一个单词的首字母
HQL查询及语法
HQL查询及语法,java web开发必备。
java中的hql语句查询语句_JavaWeb_(Hibernate框架)Hibernate中数据查询语句HQL基本用法...
HQL(Hibernate Query Language) 是面向对象的查询语言, 它和 SQL 查询语言有些相似. 在 Hibernate 提供的各种检索方式中, HQL 是使用最广的一种检索方式.,HQL查询包括以下步骤:1、获取HibernateSession对象2、编写HQL语句3、以HQL语句作为参数,调用Session的createQuery方法创建查询对象。4、如果HQL语句包含...
西门子PLC新手必看:200SMART与1200/1500的MODBUS RTU通讯实战(附完整配置流程)
本文详细解析了西门子PLC中S7-200 SMART与S7-1200/1500之间实现MODBUS RTU通讯的完整实战流程。内容涵盖硬件接线、软件配置及程序编写,重点讲解了200SMART作为从站、1200/1500作为主站的典型架构,并提供了关键功能块的使用方法和常见问题排查技巧,帮助新手快速打通不同系列PLC间的数据交换。
Rstudio安装org.Hs.eg.db
自己也是个小白,初次安装org.Hs.eg.db碰到好多问题,步骤总结如下: 第一,instal.packages()安装,不行则换 BiocManager::install() 第二,如BiocManager不成,说明不是最新版本,可按提示安装最新版 BiocManager::install(version = '3.13') #由于R版本较新,按照提示中的相关信息,安装最新版本的 第三,再次安装 BiocManager::install("org.Hs.eg.db") 第四,之后每个人.
HQL查询
HQL查询:Criteria查询对查询条件进行了面向对象封装,符合编程人员的思维方式,不过HQL(Hibernate Query Lanaguage)查询提供了更加丰富的和灵活的查询特性,因此Hibernate将HQL查询方式立为官方推荐的标准查询方式,HQL查询在涵盖Criteria查询的所有功能的前提下,提供了类似标准SQL语句的查询方式,同时也提供了更加面向对象的封装。完整的HQL语
ArcGISPro应用指南:ArcGISPro制图全流程详解
本文介绍了基于ArcGIS Pro的地图制作基本流程,旨在帮助读者快速掌握从数据加载到地图输出的完整制图操作。文章首先简要概述了GIS技术在当今数据驱动时代的重要作用,并引出ArcGIS Pro作为专业GIS平台的优势与应用价值。随后,内容围绕地图制作的核心步骤展开,包括数据加载、布局创建、地图范围设置以及各类地图要素(如指北针、比例尺、图例、图名)的插入与样式调整。此外,还介绍了如何通过添加图形、文本及动态元素增强地图表达效果,并最终完成地图导出设置与文件输出格式的选择。
常用的Hql语句
光给面试题不给答案不是我的风格。这里面的面试题也只是凤毛麟角,还有答案的话会极大的增加文章的篇幅,减少文章的可读性。
手把手教你用Multisim搭建FM直接调频电路(附完整波形分析)
本文通过Multisim仿真软件,手把手教你搭建FM直接调频电路。详细介绍了从核心概念理解、压控振荡器(VCO)参数设置、电路搭建与波形观测,到带通滤波器设计与信号优化的完整流程。通过对比滤波前后的时域波形与频谱分析,帮助读者直观理解频率调制原理,并提供了常见问题的排查思路与参数调试方法,将抽象的通信理论转化为可操作的实践技能。
PX4 磁罗盘干扰分析
无人机上的电机电流会干扰无人机上搭载的磁罗盘,PX4官方提供了一些方式,通过分析飞行日志,判断电机是否对磁罗盘有严重影响。
java中的hql语句查询语句_【java】【转】HQL查询语句
/****/packagecom.b510.example;importjava.util.Iterator;importjava.util.List;importjava.util.Map;importorg.hibernate.Criteria;importorg.hibernate.FetchMode;importorg.hibernate.Query;importorg.hibernate...
【数学建模】编程手学习路线
在学习过程中,建议注重理论与实践相结合,多进行实例练习和项目实践,以巩固所学知识并提升实际应用能力。同时,保持对新技术和新方法的关注和学习,不断提升自己的专业素养和竞争力。NumPy、Pandas、Matplotlib和Seaborn等库是数据处理和可视化的重要工具。掌握常用机器学习算法的原理和应用,如决策树、支持向量机、神经网络等。学习内容包括微积分、线性方程组、矩阵运算、概率分布、统计推断等。学习内容包括基本语法、函数和模块、面向对象编程、文件操作等。深入了解优化理论和方法,如梯度下降法、牛顿法等。
hql语句的语法
原文地址:hql语句的语法作者:毛义法 一、HQL查询的from子句 from是最简单的语句,也是最基本的HQL语句。from关键字后紧跟持久化类的类名。 例如: from Person 表明从Person持久化类中选出全部的实例 推荐为Person持久化类的每个实例起别名,例如: from Person as p p作为Person的实例的别名,因此也应该遵守Java的命名
Ubuntu24.04/20.04设置网络共享文件夹
Ubuntu20.04利用向日葵远程控制时,不能传输文件。使用linux版本QQ来传输是可以的,不过linuxqq功能真的很弱。因此,打算在Ubuntu系统中建立一个共享文件夹,可在局域网中访问。 1、新建共享文件夹 获取root权限,或者登陆root账户。可在/home文件夹(或其它文件夹)下新建一个文件夹,如share。 右击文件夹,选择“本地网络共享”菜单。按下图设置。 点击确定。如果系统已经安装了samba服务器,就可以进入第3步。如果没有,会提示安装,按提示安装,可能会出错,可进.
【002】C++ 语言核心:关键字深度解析与分类指南
auto:自动类型推导bool:布尔类型break:跳出循环或switch语句case:switch语句分支char:字符类型class:定义类const:常量continue:结束当前循环,开始下一次循环default:switch语句默认分支delete:删除对象do:do-while循环double:双精度浮点数类型else:if语句的否定分支enum:枚举类型explicit:显式构造函数export:导出符号extern:声明外部变量或函数。
hibernate HQL语句+语法【大全】
HQL:Hibernate Query Language HQL是完全面向对象的查询语言,因此可以支持继承和多态等特征。 HQL查询依赖于Query类,每个Query实例对应一个查询对象,使用HQL查询按 如下步骤进行: (1)获取Hibernate Session对象; (2)编写HQL语句; (3)以HQL语句作为参数,调用Session的createQuery方法创建查询对象; (4)如果H
C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片
基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正
HQL语句的语法
1.from子句 from Person 表明从Person持久化类中选出全部的实例。 推荐:from Person as p 2.select子句 select p.name from Person as p select p.name.firstName from Person as p select new list(p.name, p.address) from Pers
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版
Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。
HQL语句的基本语法和使用
HQL查询Criteria查询对查询条件进行了面向对象封装,符合编程人员的思维方式,不过HQL(Hibernate Query Lanaguage)查询提供了更加丰富的和灵活的查询特性,因此Hibernate将HQL查询方式立为官方推荐的标准查询方式,HQL查询在涵盖Criteria查询的所有功能的前提下,提供了类似标准SQL语句的查询方式,同时也提供了更加面向对象的封装。完整的HQL语句形势...
VB摄像头监控
该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制
Hibernate 查询语句HQL基本语法
Criteria查询对查询条件进行了面向对象封装,符合编程人员的思维方式,不过HQL(Hibernate QueryLanguage)查询提供了更加丰富的和灵活的查询特性,因此Hibernate将HQL查询方式立为官方推荐的标准查询方式,HQL查询在涵盖Criteria查询的所有
HQL语句的语法(笔记一)
一、HQL查询的from子句 from是最简单的语句,也是最基本的HQL语句。from关键字后紧跟持久化类的类名。 例如: from Person 表明从Person持久化类中选出全部的实例 推荐为Person持久化类的每个实例起别名,例如: from Person as p p作为Person的实例的别名,因此也应该遵守Java的命名规则:第一个单词的首字母...
HQL语句的语法(笔记二)
四、HQL查询的select子句 (1)select子句用于选择指定的属性或直接选择某个实体,当然select选择的属性必须是from后持久化类包含的属性。 例如: select p.name from Person as p (2)select可以选择任意属性,即不仅可以选择持久化类的直接属性,还可以选择组件属性包含的属性。例如: select p.name.fir...
hibernate HQL语句+语法【大全】
HQL:Hibernate Query Language HQL是完全面向对象的查询语言,因此可以支持继承和多态等特征。 HQL查询依赖于Query类,每个Query实例对应一个查询对象,使用HQL查询按 如下步骤进行: (1)获取Hibernate Session对象; (2)编写HQL语句; (3)以HQL语句作为参数,调用Session的createQuery方法创建查询对象; (4)如果H
814



被折叠的 条评论
为什么被折叠?



