hibernate的自关联注解类

Grails Grails 与 Hibernate   Grails 与 Hibernate 如果 GORM (Grails Object Relational Mapping)没有你想象的那么足够灵活,作为选择,你可以使用Hibernate映射你的domain类. 要做到这点,需要在你项目的grails-app/conf/hibernate目录创建一个hibernate.cfg.xml文件并为你的domain类对应HBM映射文件 ... 阅读详情

数据库表

CREATE TABLE `sys_menus` (
  `menu_id` int(11) NOT NULL AUTO_INCREMENT,
  `menu_name` varchar(255) NOT NULL,
  `menu_url` varchar(255) DEFAULT NULL,
  `menu_pid` int(11) DEFAULT NULL,
  `sys_ico` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`menu_id`),
  KEY `FK_bjl014ucbcba3uglobyj6slb5` (`menu_id`),
  CONSTRAINT `FK_bjl014ucbcba3uglobyj6slb5` FOREIGN KEY (`menu_id`) REFERENCES `sys_menus` (`menu_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

实体类

@Table(name = "sys_menus")
@Data
@Entity
public class Menu {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="menu_id")
    private Long menuId;
    @Column(name="menu_name")
    private String menuName;
    @Column(name="menu_url")
    private String menuUrl;
    @Column(name="sys_ico")
    private String sysIco;
    @Column(name="menu_pid")
    private Long menuPid;
    @OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER,targetEntity = Menu.class)   
    @JoinColumn(name="menu_pid")
    private List<Menu> menus;


}

结果

[Menu(menuId=1, menuName=项目管理, menuUrl=, sysIco=fa fa-bullhorn, menuPid=0, menus=[Menu(menuId=2, menuName=人员管理, menuUrl=/admin/user/toUserpage, sysIco=, menuPid=1, menus=[])])]
hibernate自身关联一对多实例(树形结构) NULL 博文链接:https://fangguanhong.iteye.com/blog/1735492 立即下载

相关推荐

Hibernate一对多关联映射(注解)

NULL 博文链接:https://profound-accumulation.iteye.com/blog/2243079

Hibernate注解版关联关系映射全解析+案例

给大家送一个小福利附高清脑图,高清知识点讲解教程,以及一些面试真题及答案解析。送给需要的提升技术、准备面试跳槽、自身职业规划迷茫的朋友们。《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!注意[java]view plaincopy[外链图片转存中…(img-6F15TKWf-1713854767554)][外链图片转存中…(img-mjs0fzEU-1713854767554)]

m0_72758098的博客 878

基于注解的关联关系Hibernate

介绍使用Hibernate注解来进行关联关系的配置,结合我的博客文章阅读更方便理解。

hibernate注解表的自关联

@ManyToMany(mappedBy = "friends", cascade = { CascadeType.PERSIST }, fetch = FetchType.LAZY) private List<User> owns; @ManyToMany(cascade = { CascadeType.PERSIST }, fetch = FetchTyp...

didaoxiu6491的博客 175

unity C# 计算3D空间任意多边形面积,距离,角度测量工具

unity C# 计算3D空间任意多边形面积,距离,角度 using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using System; /// /// 划线面积,距离,角度 /// public class UnderlinedMeasureTool : MonoBehaviour { /// /// 相机 /// public Camera _c

qq_22972867的博客 2224

深度学习 load_data_fashion_mnist

pytorch 中报错:PermissionError: [WinError 5] 拒绝访问。: '…/data’ 在学习李沐大神动手学习深度学习卷积神经网络章节中,调用d2l包中load_data_fashion_mnist报错,这可能是***权限***的问题。 batch_size = 256 train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size,batch_size) 我的解决方法是 重新定义一下 load_data_fashi

纸上得来终觉浅,绝知此事要躬行 9148

Hibernate 自关联注解方式

Hibernate自关联(使用注解) HibernateSQL配置管理数据结构Cache  今天下午搞了个使用注解的自连接一对多,以前用的都是配置文件,突然间用注解,一下子没找到方向,所以记录下来。 主要是现实一个多级菜单。 表结构: Sql代码   create table SMS_MENU   (     ID     NUMBER no...

男人可以没有钱,但不可以没有责任感 288

【学习路线】 游戏客户端开发入门到进阶

游戏开发是一个交叉性极强的技术领域,对开发者提出了高维度的要求。作为初学者,不要急于求成,打牢基础、注重原理、勤于实践,你的成长将会非常快速而稳健。希望这份学习路线与书单能为你指明方向,迈出职业开发者的第一步。

hhw_hhw的博客 2128

hibernate学习-两表关联(一对多,多对多,自关联)注解配置-第6天

  关联关系,是使用最多的一种关系,非常重要。在内存中反映为实体关系,映射到 DB 中为主外键关系。实体间的关联,即对外键的维护。关联关系的发生,即对外键数据的改 变。外键:外面的主键,即,使用其它表的主键值作为自已的某字段的取值。 一、基本概念 前4个请查看 Hibernate5讲义 5、关联方向 (1)单向关联 指具有关联关系的实体对象间的加载与访问关系是单向的。即,只有一个实体对象可 以加载...

chegy218的博客 442

spyglass之功耗分析

用于功耗分析的软件除了ptpx外,spyglass也可以。ptpx的功耗分析是基于netlist(网表)进行的,一般用于分析综合后的pre功耗和P&R后的post功耗,但这已经是项目进行到比较后期了,如果后期发现功耗数据与我们目标功耗相差较大,则意味着需要功耗优化,这时有可能会将项目计划节点延迟。如果在前期designer可以获得设计模块的功耗数据,可提早优化功耗,spyglass则为designer提供了一个很好的手段去评估功耗,从而提前优化功耗。

u011974971的博客 9199

使用 Python 调用 GitHub REST API 爬取 GitHub 仓库信息(完整指南)

GitHub 提供了功能强大的 REST API,允许开发者通过编程方式访问 GitHub 上的仓库、用户、提交记录、PR(Pull Request)等信息。GitHub REST API 是 GitHub 官方提供的 API 接口,支持通过 HTTP 请求来操作 GitHub 上的资源。在本文中,我们将使用 Python 编写一个完整的爬虫程序,调用 GitHub 的 REST API 来爬取 GitHub 仓库的信息。目前 GitHub 使用的主要是 v3 版本的 REST API。

2201_76125261的博客 1111

Hibernate注解方式一对多自关联关系映射

Hibernate注解方式一对多自关联关系映射(多级分类功能)

weixin_42823019的博客 368

音频链路分析

音频链路分析摘要 本文分析了蓝牙音频设备(BES2700)的音频传输链路,主要包括通话和音乐播放两种场景: 通话链路: 下行:蓝牙接收数据→解码→通过Codec输出到扬声器 上行:麦克风采集→Codec处理→蓝牙编码发送 音乐播放链路: 通过A2DP协议接收高质量音频数据 经过解码、EQ调节等音频处理后输出 系统采用多线程消息机制处理音频任务,通过mailbox传递控制消息,由回调函数处理具体音频数据流。不同应用场景使用不同的蓝牙协议栈(HFP/HSP用于通话,A2DP用于媒体)和编码方式(mSBC/SBC

云淡风轻 85

Hibernate注解类介绍

介绍 本文介绍了Hibernate中的一些注解类。 未完待续。。。 查看原文:http://surenpi.com/2016/06/16/hibernate_annotation_class_intro/

Jenkins中文社区 291

AWS SQS跨账户访问失败排查指南

在使用AWS SQS(Simple Queue Service)时,跨账户访问是常见的业务场景。例如,账户A的应用程序向队列发送消息,账户B的消费者从队列拉取消息。尽管AWS官方文档明确支持此类配置,但在实际应用中,由于权限模型的复杂性,开发者和运维人员常会遇到“策略已配置但无法接收消息”的问题。通过本文的逐步排查指南,您不仅可以解决当前问题,还能深入理解AWS跨账户访问的权限模型。接收方账户的用户或角色必须同时附加IAM策略,显式授权操作目标队列。尽管策略看似允许接收方操作,实际测试中却返回空消息或。

探索云原生与智能化驱动下的安全运维新范式。关注DevSecOps、可观测性、AIOps等前沿领域,与您共赴技术前沿。 458

多模型机器学习生存预测分析:AUC比较、生存分层与SHAP解释

本文研究了多种机器学习模型在心力衰竭患者生存预测中的应用。通过比较逻辑回归、随机森林、XGBoost、LightGBM和梯度提升机五种模型的AUC表现,选择最优预测模型。基于最优模型的预测概率对患者进行风险分层,并使用Kaplan-Meier生存分析和log-rank检验验证分层的有效性。最后采用SHAP方法解释模型决策过程,识别关键预测因素。研究提供了从模型构建、评估到解释的完整技术流程,为临床预后预测提供了可复现的分析框架。

AI的内部世界的博客 157

eclipse生成Hibernate注解类【续】

【1】打开 Hibernate Configurations模块,新增Add Configuration 选择数据库: 选择UTF-8编码: 生成代码注解类:

u013551536的博客 348

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Hibernate注解类的使用

首先先加入注解类的三个必要的包 主键上面写上id注解 这时候是一个类所以要用.作为路径 因为用了注解所以要用AnnotationConfiguration()注解的配置文件获取方法 ...

chongtingge6113的博客 115

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Oracle + Hibernate注解类 实现主键自动增长

1、创建序列     sql创建代码:    create sequence TLM_PACKLIST_ITEM_SEQ minvalue 1 maxvalue 999999999999999999 start with 1 increment by 1 cache 20; 2、我是在 MyEclipse 数据库视图中用反向工程自动生成的注解类。   添加序列名属性:   @Id  @S

522

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

让Spring自动加载Hibernate 注解类

<br /> 让Spring自动加载Hibernate 注解类<br /><br /><br />通常,spring整合Hibernate的SessionFactory是这样做的:<br /><br />XML代码<br /><property name="annotatedClasses"> <LIST></LIST><VALUE></VALUE>com.systop.common.core.dao.testmodel.TestDept </property> <property name="

xinew的专栏 1901

Hibernate自定义注解类

介绍 Hibernate对PO类上支持的注解类是有限的,而且我用的这个版本的Hibernate还不支持在生成数据库表(通过hibernate.hbm2ddl.auto)时生成字段注释(comment)。 本文通过扩展AnnotationSessionFactoryBean和AnnotationConfiguration来实现的,如果各位看客还有更好的主意的话,还希望能多多交流。 例子 [co

Jenkins中文社区 1011

JPA注解类介绍

介绍 本文介绍了JPA持久化框架中的一些注解类,以方便各位查询。  未完待续。。。 查看原文:http://surenpi.com/2016/06/16/jpa_annotation_class_intro/

Jenkins中文社区 278

hibernate validator

背景 我们在编写接口的时候、一定会有校验入参是否合法的需求,比如校验入参是否为空、是否为数字、是否是合法日期格式等等。此类需求如果使用代码去实现也不复杂、不过每个接口都去做重复工作就不是很合理,基于此,hibernate validator提供了一系列的注解,为我们完成这些工作 使用方式 1、 校验字符串不能为空 在对象的属性中,添加@NotEmpty注解 public class User ...

maniacer的博客 823

ideaJPA实现mysql_idea hibernate jpa 生成实体类的实现

idea hibernate jpa 生成实体类的实现发布时间:2020-08-30 01:09:35来源:脚本之家阅读:121作者:走过程序员的路本篇博客记录下 IDEA 中连接数据库反转生成 Hibernate 实体和配置文件。1. 打开 DataBase 窗口,添加数据源到了这一步数据源已添加好。2. 添加 hibernat 持久层支持,生成实体 Bean /配置文件,这一步要去plugs那...

weixin_39979215的博客 204

hibernate实体注解类详解

@Entity //继承策略。另一个类继承本类,那么本类里的属性应用到另一个类中 @Inheritance(strategy = InheritanceType.JOINED ) @Table(name="INFOM_TESTRESULT") public class TestResult extends IdEntity{}   1、@E

Caster_Saber的专栏 579
上一篇: JAVA WEB中利用@responsebody返回json
下一篇: Bootstrap fileinput的图片上传 java框架基于springMVC
Java_chaozi
博客等级 码龄11年 11粉丝 13原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值