我的问题存在一个无级分类树中,因为对HQL语句不熟悉,所以想请
实际的sql语句如下:
select * from DictionaryLib where fk_dictionary_lib_parent_id is null and fk_dictionary_id=1
我尝试在createsqlquery中写如下代码,但是出错
java 代码
- String sql="select {d.*} from DictionaryLib d where {d.fk_dictionary_lib_parent_id} is null and {d.fk_dictionary_id}="+String.valueOf(dictionaryId);
肯请指点
下面我解释一下我的表结构,相关的有两张,
一张是DictionaryLib(即字典库表),该表构成一棵无级分类的树
pk_dictionary_lib_id是主键
fk_dictionary_lib_parent_id是该类的父类的id,若为顶类则为null
fk_dictionary_id是表dictionary字典表的外键,通过这个外键可以知道,每个类属于哪个字典
java 代码
- package com.lexus.bean;
-
- import java.util.Date;
- import java.util.HashSet;
- import java.util.Set;
-
-
-
-
-
-
- public abstract class AbstractDictionaryLib implements java.io.Serializable {
-
-
-
-
- private Integer pkDictionaryLibId;
- //该类的父结点对象
- private DictionaryLib dictionaryLib;
- //该类关联的字典对象
- private Dictionary dictionary;
- private String name;
- private String description;
- private Integer sequence;
- private Short depth;
- private Date checkinTime;
- private Date updateTime;
- private Short version;
- private String status;
- private Set attachmentsForExtendName = new HashSet(0);
- private Set attachmentsForAttachmentType = new HashSet(0);
- //该类子结点集
- private Set dictionaryLibs = new HashSet(0);
-
-
-
-
-
- public AbstractDictionaryLib() {
- }
-
-
- public AbstractDictionaryLib(Dictionary dictionary, String name) {
- this.dictionary = dictionary;
- this.name = name;
- }
-
-
- public AbstractDictionaryLib(DictionaryLib dictionaryLib, Dictionary dictionary, String name, String description, Integer sequence, Short depth, Date checkinTime, Date updateTime, Short version, String status, Set attachmentsForExtendName, Set attachmentsForAttachmentType, Set dictionaryLibs) {
- this.dictionaryLib = dictionaryLib;
- this.dictionary = dictionary;
- this.name = name;
- this.description = description;
- this.sequence = sequence;
- this.depth = depth;
- this.checkinTime = checkinTime;
- this.updateTime = updateTime;
- this.version = version;
- this.status = status;
- this.attachmentsForExtendName = attachmentsForExtendName;
- this.attachmentsForAttachmentType = attachmentsForAttachmentType;
- this.dictionaryLibs = dictionaryLibs;
- }
-
-
-
-
- public Integer getPkDictionaryLibId() {
- return this.pkDictionaryLibId;
- }
-
- public void setPkDictionaryLibId(Integer pkDictionaryLibId) {
- this.pkDictionaryLibId = pkDictionaryLibId;
- }
-
- public DictionaryLib getDictionaryLib() {
- return this.dictionaryLib;
- }
-
- public void setDictionaryLib(DictionaryLib dictionaryLib) {
- this.dictionaryLib = dictionaryLib;
- }
-
- public Dictionary getDictionary() {
- return this.dictionary;
- }
-
- public void setDictionary(Dictionary dictionary) {
- this.dictionary = dictionary;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Integer getSequence() {
- return this.sequence;
- }
-
- public void setSequence(Integer sequence) {
- this.sequence = sequence;
- }
-
- public Short getDepth() {
- return this.depth;
- }
-
- public void setDepth(Short depth) {
- this.depth = depth;
- }
-
- public Date getCheckinTime() {
- return this.checkinTime;
- }
-
- public void setCheckinTime(Date checkinTime) {
- this.checkinTime = checkinTime;
- }
-
- public Date getUpdateTime() {
- return this.updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public Short getVersion() {
- return this.version;
- }
-
- public void setVersion(Short version) {
- this.version = version;
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public Set getAttachmentsForExtendName() {
- return this.attachmentsForExtendName;
- }
-
- public void setAttachmentsForExtendName(Set attachmentsForExtendName) {
- this.attachmentsForExtendName = attachmentsForExtendName;
- }
-
- public Set getAttachmentsForAttachmentType() {
- return this.attachmentsForAttachmentType;
- }
-
- public void setAttachmentsForAttachmentType(Set attachmentsForAttachmentType) {
- this.attachmentsForAttachmentType = attachmentsForAttachmentType;
- }
-
- public Set getDictionaryLibs() {
- return this.dictionaryLibs;
- }
-
- public void setDictionaryLibs(Set dictionaryLibs) {
- this.dictionaryLibs = dictionaryLibs;
- }
-
-
- }
分享到:
相关推荐
hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全hql语句大全
HQL语句大全HQL语句大全HQL语句大全HQL语句大全HQL语句大全
HQL语句 HQL语句 HQL语句 HQL语句 HQL语句
非常详细直接实用的HQL语句的功能介绍 看过的人保准都说好
hibernate-HQL语句大全
HQL语句的语法,很基础
HQL语句大全
hql语句大全
常见HQL语句的示例包括输出结果,以及语句的分析总结
hql语句常规 方法 使用 了解hql语句
hibernate 中HQL语句查询学习笔记
HQL语句的用法,关于HQL与SQL语句的比较及其用法。
HQL语句查询
解析内容清晰简单,让你对hql语句半天就可以掌握!!
下面介绍HQL语句的语法 1.from子句 2.select子句 3.聚集函数 4.多态查询 5.where子句 6.表达式 7.order by子句 8.group by子句 9.子查询语句 10.fetch关键字 11.命名查询
汇集了hql语句中大部分常用的函数 ABS(n) 取绝对值数学函数 数学函数 JPAQL HQL ABS(column_name[数字类型对象属性])
HQL语句(结合实例).doc HQL语句(结合实例).doc HQL语句(结合实例).doc
整理的hql语句 id生成策略 集合传参,传参方式等 应有尽有
HQL语句(结合实例)HQL语句(结合实例)HQL语句(结合实例)HQL语句(结合实例)HQL语句(结合实例)
hibernate hql语句 经典教程 实用 全面