(转)iBaits中SqlMapClientTemplate的使用

LAMMPS实战:如何用ReaxFF力场模拟碳氢化合物热解(附完整脚本) 本文提供了一份使用LAMMPS软件中ReaxFF反应力场模拟碳氢化合物热解过程的完整实战指南。内容涵盖从环境准备、力场参数选择、能量最小化,到升温恒温动力学模拟的完整脚本编写,并介绍了基于轨迹文件的产物分析方法,帮助计算化学与材料科学研究者快速上手这一关键的分子动力学仿真技术。 阅读详情
Apache iBatis(现已迁至Google Code下发展,更名为MyBatis)是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库的操作拥有更加灵活的控制,对于那些经常需要调用本地数据库函数自定义SQL语句,或是喜欢自己优化SQL执行效率的开发者来说,iBatis是一个非常不错的选择。而得到广泛应用的开源企业架构SpringFramework,也很好的将其进行了集成,使得iBatis在 SpringFramework中的使用更加便利、快捷。开发者所要做的就是继承SpringFramework中提供的 SqlMapClientDaoSupport类即可。下面,我将自己的使用经验与大家分享一下: 

1、SqlMapClientFactoryBean 的装配 
    SqlMapClientFactoryBean是SqlMapClientTemplate使用的基础,如果在 
SpringFramework应用中没有装配SqlMapClientFactoryBean,那么SqlMapClientTemplate将不可用,报空指针错误。 
Java代码   收藏代码
  1. <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">  
  2.     <property name="configLocation" value="/WEB-INF/sqlmap-config.xml"/> <!-- iBatis sqlmap config 文件位置 -->  
  3.     <property name="dataSource" ref="dataSource"/> <!-- 在SpringFramework配置文件中使用的数据源 -->  
  4.     <property name="lobHandler" ref="oracleLobHandler"/> <!-- 如果需要读写Lob字段,需要注入在SpringFramework配置文件中配置好的Handler,这里是Oracle的数据库 -->  
  5. </bean>  

2、继承使用SqlMapClientDaoSupport类 
声明Java类: 
Java代码   收藏代码
  1.    ......  
  2.     import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;  
  3.     ......  
  4.     public class ReportDAOImpl extends SqlMapClientDaoSupport {  
  5.         ......  
  6.     }  
  7.   
  8. SpringFramework配置文件中装配Java类:  
  9.     <bean id="reportDao" class="com.test.dao.ReportDAOImpl">  
  10.         <property name="sqlMapClient" ref="sqlMapClient"/> <!-- 装配SqlMapClientFactoryBean -->  
  11.     </bean>  


3、使用SqlMapClientTemplate查询 
Java代码: 
    当执行没有参数的查询时: 
Java代码   收藏代码
  1. List result = getSqlMapClientTemplate().queryForList("TestSpace.qryTest");  

        "TestSpace"为iBatis SqlMap文件的命名空间;"qryTest"为iBatis SqlMap的查询方法id 

    当按照主键获取某条记录信息时: 
  
Java代码   收藏代码
  1. Long id = new Long("2");  
  2.    Object resultObj = getSqlMapClientTemplate().queryForObject("TestSpace.getTest", id);  


    当按照某些条件查询时: 
   
Java代码   收藏代码
  1. ObjectA objA = new ObjectA();  
  2.     objA.setParam1("test1");  
  3.     objA.setParam2("test2");  
  4.     ......  
  5.     List result = getSqlMapClientTemplate().queryForList("TestSpace.qryTestByParam", objA);  

    如果需要取4~40条数据: 
    List result = getSqlMapClientTemplate().queryForList("TestSpace.qryTestByParam", objA, 4, 40); 
    也可以返回Map 
  
Java代码   收藏代码
  1. Map result = getSqlMapClientTemplate().queryForMap("TestSpace.qryTestByParam", objA, "MapKey");  

4、使用SqlMapClientTemplate添加数据 
Java代码: 
    ObjectA objA = new ObjectA(); 
  
Java代码   收藏代码
  1. objA.setParam1("test1");  
  2.    objA.setParam2("test2");  
  3.    ......  
  4.    getSqlMapClientTemplate().insert("TestSpace.insertTest", objA);  

5、使用SqlMapClientTemplate更新数据 
Java代码: 
   
Java代码   收藏代码
  1. ObjectA objA = new ObjectA();  
  2.     objA.setParam1("test1");  
  3.     objA.setParam2("test2");  
  4.     ......  
  5.     getSqlMapClientTemplate().update("TestSpace.updateTest", objA);  

    更新前20条记录: 
   
Java代码   收藏代码
  1. getSqlMapClientTemplate().update("TestSpace.updateTest", objA, 20);  

6、使用SqlMapClientTemplate删除数据 
Java代码: 
  
Java代码   收藏代码
  1. Long id = new Long("2");  
  2.    getSqlMapClientTemplate().delete("TestSpace.deleteTest", id);  
【codex教程】Codex 注册和使用教程(2026最新版) Codex 是 OpenAI 推出的 AI 编程助手,可以帮助开发者阅读代码、修改代码、运行命令、生成测试、排查 bug、做代码审查,也可以在终端、IDE、Codex App 或网页端使用。根据 OpenAI 帮助中心,截至 2026 年 6 月,Codex 已包含在 Free、Go、Plus、Pro、Business、Edu 和 Enterprise 等 ChatGPT 方案中,但不同套餐的使用额度会有所不同。适合开发者在终端中使用。如果你想在命令行里使用 Codex,可以安装 Codex CLI。 阅读详情

相关推荐

Mplus—随机截距交叉滞后模型(Random Intercepts Cross-Lagged Panel Model, RI-CLPM)

介绍随机截距交叉滞后模型(Random Intercepts Cross-Lagged Panel Model, RI-CLPM)的相关知识,例如模型内容、Mplus语法及对应网址等。

m0_54401011的博客 9532

在spring中使用SqlMapClientTemplate操作数据库

SqlMapClientTemplate是SqlMapClient的封装类。 SqlMapClient是ibatis的。但SpringFramework,也很好的将其进行了集成,我们要做的就是继承SpringFramework中提供的SqlMapClientDaoSupport类即可。 在springFramework的org.springframework.orm.ibatis组件中。 S

天外来客的博客 3万+

AIDD-人工智能药物设计-构建基于机器学习方法的在线预测平台高准确预测药物诱导骨毒性

在此基础上,提取多种药物分子特征,包括分子指纹(如MACCS、Morgan、RDKit、TopologicalTorsion、AtomPairs与Descriptors)及分子图谱,通过Transformer编码器与神经网络进行机器学习模型训练。最后,将训练好的模型部署为在线Web服务器(BoneToxPD),供用户快速预测药物的骨毒性。本研究不仅在骨毒性预测的准确性方面取得了突破,还在模型解释性方面提供了新的视角,通过注意力机制精准识别出影响骨毒性的关键化学基团,推动药物研发领域更安全、更高效的发展。

itwangyang520的博客 1079

SqlMapClientTemplate用法

Person.java----------------------------------------------------------------------------- package ajdbc.bean; public class Person { private Long id; private String name; public Person()

wuruiaoxue的专栏 4188

DDR3性能优化实战:如何用Xilinx MIG控制器实现800MHz稳定读写(7系列FPGA版)

本文深入探讨了在Xilinx 7系列FPGA上使用MIG控制器实现DDR3存储器800MHz稳定高速读写的实战优化技巧。文章聚焦于高级时序调优、Bank Machine调度策略、用户接口设计优化以及利用ILA进行信号完整性调试,旨在帮助工程师突破性能瓶颈,实现接近理论峰值的稳定带宽,并为进一步冲刺更高频率提供进阶调参指南。

seed的博客 775

避开这5个坑!用MATLAB做核密度估计时90%人会犯的错误

本文详细解析了使用MATLAB进行核密度估计时常见的5个高频错误,包括三维数据可视化、带宽参数优化、大数据量处理、核函数选择及版本兼容性问题。特别针对核密度估计中的关键参数带宽(bandwidth)提供了数据驱动的优化策略,帮助用户提升分析精度与效率。

jenkins8butler的博客 277

SqlMapClientTemplate的几种初始化方式

SqlMapClientTemplate 是 使用ibatis是必然会用到的一个类。下面介绍三种不同方式初始,其实大同小异,在此做个   总结,以备不时之需。   第一种:在applicationContext.xml中配置SqlMapClient的   configLocation和dataSource两个属性的值,再利用SqlMapClientTemplate 类的setSqlMa...

zhangmiao12的专栏 775

UG NX二次开发(C#)-外部模式-批量删除某些图层中的体对象和曲线对象

在 UG NX中,有时需要批量删除某文件夹下多个.prt文件中固定一些图层中的体对象和曲线对象,这时如果采用手动逐个打开模型,并选择针对的图层删除,即耗时也容易遗漏,因此采用外部模式来处理比较方便。本文介绍批量删除某些图层中的体对象和曲线对象。

GimiGimmy 3035

ibaits知识之Dao

前言 HibernateDaoSupport SqlMapClientDaoSupport 。 其实就作用而言两者是一样的,都是为提供DAO支持,为访问数据库提供支持。 只不过HibernateDaoSupport是Spring对Hibernate的支持,而SqlMapClientDaoSupport是Spring对ibatis的支持。Hibernate是一个全自动化的ORM框架,而Ibati...

qq_31217363的博客 387

C#WPF常用的9种布局方式详解

本文介绍WPF中常用的九种布局,Grid、StackPanel、WrapPanel、DockPanel、UniformGrid、Canvas、ScrollViewer、ViewBox、Border。

qq_30725967的博客 1万+

Ardupilot二次开发(二):自定义mavlivk消息

在下面的文件添加自定义消息的xml定义然后编译固件,会生成相应的消息头文件。

超维空间科技的博客 2312

iBaits中SqlMapClientTemplate的使用

Apache iBatis(现已迁至Google Code下发展,更名为MyBatis)是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库的操作拥有更加灵活的控制,对于那些经常需要调用本地数据库函数自定义SQL语句,或是喜欢自己优化SQL执行效率的开发者来说,iBatis是一个非常不错的选择。而得到广泛应用的开源企业架构SpringFr

奋斗、 5970

【YoloV8改进策略】上采样改进|EUCB,轻量高效的上采样模块|即插即用

YOLOv8作为当前最先进的实时目标检测与实例分割模型之一,其在速度与精度之间取得了出色的平衡。然而,在资源受限的边缘设备或对实时性要求极高的应用场景中,YOLOv8的计算开销,尤其是在特征金字塔网络(FPN)和路径聚合网络(PAN)中用于特征融合的上采样操作,仍然是一个瓶颈。YOLOv8的颈部(Neck)结构中广泛使用nn.Upsample进行上采样,该操作虽然简单,但缺乏对特征内容的感知能力,且后续通常需要标准卷积来修复因插值带来的伪影,这增加了不必要的计算负担。

m0_47867638的博客 752

iBaits中SqlMapClientTemplate的使用【转】

为什么80%的码农都做不了架构师?>>> ...

weixin_34291004的博客 161

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

详解iBaits中SqlMapClientTemplate的使用

Apache iBatis(现已迁至Google Code下发展,更名为MyBatis)是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库的操作拥有更加灵活的控制,对于那些经常需要调用本地数据库函数自定义SQL语句,或是喜欢自己优化SQL执行效率的开发者来说,iBatis是一个非常不错的选择。而得到广泛应用的开源企业架构SpringFr...

毛兔记录:工作小技巧、遇到的一些典型bug、问题汇总、小知识。 803

深度学习工具包 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")

iBaits中SqlMapClientTemplate及SqlMapClientTemplate的使用

Apache iBatis是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库的操作拥有更加灵活的控制,对于那些经常需要调用本地数据库函数自定义SQL语句,或是喜欢自己优化SQL执行效率的开发者来说,iBatis是一个非常不错的选择。而得到广泛应用的开源企业架构SpringFramework,也很好的将其进行了集成,使得iBatis在 S

sunny_na的博客 1979

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

iBaits中SqlMapClientTemplate的使用及方法

 Apache iBatis是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库的操作拥有更加灵活的控制,对于那些经常需要调用本地数据库函数自定义SQL语句,或是喜欢自己优化SQL执行效率的开发者来说,iBatis是一个非常不错的选择。而得到广泛应用的开源企业架构SpringFramework,也很好的将其进行了集成,使得iBati

shixiaoguo90的专栏 3111

iBaits集成Spring SqlMapClientTemplate的使用

Apache iBatis(现已迁至Google Code下发展,更名为MyBatis)是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库的操作拥有更加灵活的控制,对于那些经常需要调用本地数据库函数自定义SQL语句,或是喜欢自己优化SQL执行效率的开发者来说,iBatis是一个非常不错的选择。而得到广泛应用的开源企业架构SpringFr

orclight的专栏 2882
上一篇: class sun.reflect.NativeMethodAccessorImpl请问这个类在哪里啊
下一篇: GridPanel中getSelectionModel
javaPie
博客等级 码龄16年 1171粉丝 43原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值