问题标签 [ibatis.net]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
1396 浏览

xml - 配置 xml 中的 iBATIS 错误

我在我的项目中使用 iBATIS。我的 SqlMapConfig.xml 是

我收到以下错误

是什么导致了这个错误。我知道一些与 DTD 相关的东西。但是请任何人都可以提供明确的帮助吗?并请为 ibatis 推荐一个好的教程。

0 投票
2 回答
2311 浏览

java - 查询能否仅返回 Ibatis 上 resultMap 上的部分结果?

有一些使用 Ibatis 2.3 的代码,我有一个类 User 和一个 resultMap 如下:

然后我有一个只返回 id 的选择查询:

像这样,Ibatis 想要在 resultMap 上填写所有结果,并且由于它发送的查询没有返回“name”并且错误:

是否有可能以某种方式只返回 resultMap 上的部分结果的查询?

0 投票
2 回答
8979 浏览

java - Mybatis No Getter 属性

我正在使用 Mybatis 3.2.6 并实现自定义结果处理程序。在使用简单的数据类型参数之前,我已经完成了这项工作,并且没有遇到任何问题。这一次我需要传入几个参数......我使用的签名是

对于参数,我创建了一个简单的 POJO 来轻松发送我需要的内容。如下:

处理程序实现目前无关紧要,因为我提前得到了一个异常......我正在执行的查询是:

这里也是界面

我遇到的问题是通过映射器执行,例如,

工作得很好,但是当我通过会话上的选择调用时,我得到以下异常。

我已经尽可能地调试了 Mybatis,但没有运气。

提前致谢...

0 投票
2 回答
1036 浏览

c# - iBATIS.NET WebSessionStore throwing an exception

I have a web app that uses the iBATIS.NET library.

The DAO is configured by using an XmlDocument, so the code is very similar to what they show in the documentation:

The documentation says right below that:

The DaoManager instance that is built from a dao.config file is aware of all of the contexts contained within the configuration file. The context basically bundles DAO implementations together with a session handler. The DaoManager knows which DAOs and session handler belong to which context. When you request a DAO instance from the DaoManager, the proper session handler will be provided with it. Therefore, there is no need to access the context or session handler directly. Your DAO knows how it works.

This does not appear to be true. In a threaded process, the following exception is thrown randomly:

WebSessionStore: Could not obtain reference to HttpContext at IBatisNet.DataAccess.SessionStore.WebSessionStore.ObtainSessionContext() at IBatisNet.DataAccess.SessionStore.WebSessionStore.get_LocalSession()
at IBatisNet.DataAccess.DaoManager.IsDaoSessionStarted() at IBatisNet.DataAccess.Configuration.DaoProxy.Intercept(IInvocation invocation, Object[] arguments)

The application may run fine for days or even months at a time, but every once in awhile this exception is thrown. The only solution I can find mentioned anywhere is to swap out the SessionStore for a HybridWebThreadSessionStore (mentioned here).

As the documentation says above, this shouldn't be necessary. If I wanted to force it though, how would I go about overriding the SessionStore created by the DomDaoManagerBuilder?

0 投票
4 回答
5283 浏览

sql - 即使未满足 WHERE 子句,也从查询返回结果

我正在创建一个查询,以确保满足某些约束。这是现在的半工作版本:

TaskId在表中存在时可以正常工作Task,但如果该任务不存在(因此该TaskExists字段),我还需要返回值。

对于不存在的任务的查询,我希望返回

  • 任务存在 0
  • 准备就绪 0
  • DownTaskAssignedToDisfferentMachine 0

即使不TaskId存在,我如何修改我的查询以返回它?

0 投票
2 回答
1747 浏览

java - 如何使用 ibatis 注释进行批量插入

我找不到这方面的教程,而且我发现文档很少。如何使用 ibatis 注释进行批量插入?

我做了这个幼稚的实现(令人惊讶的是没有成功:-):

0 投票
0 回答
732 浏览

c# - .NET 中的 Ibatis:从 sqlmap 获取 sql 作为字符串?

是否可以将 sqlmap 中的 sql 作为字符串获取?似乎有一种方法java

所以我有一个这样的sqlmap:

在 c# 代码中,我想得到"select * from PERSON P where P.Name = #Name#".

0 投票
0 回答
52 浏览

ibatis - ibatis Serach Queston 当条件像 Like '$propertyname$%'

当我使用 ibatis 时,我有一个这样的 sql

如果我将用户名值设置为???,它会抛出异常 System.ArgumentOutOfRangeException。我知道我可以那样做

为了避免这个问题。但我不知道为什么我使用 like '%$name$%' 它会抛出异常。

0 投票
2 回答
183 浏览

java - 带有 IntegerCache 的 Java valueOf(int) 返回 valueOf(1) 的值 3

我面临IntegerCache的问题:使用内部使用 iBatis PreparedStatement 类的 iBatis 数据访问框架。

调用数据库过程,如

iBatis API 设置第一个参数时使用:

我=0,值=123

这里 ps 是对 PreparedStatement 的引用,i 是数据库过程中的参数索引。

它在内部调用

i=1,参数=123(注意:i 是 int 不是 Integer)

在内部使用 Java 反射 api 调用此调用:

方法:setInt,参数:[1, 123]

在为方法调用获取 i 的整数值时,JVM 调用下面的方法:

IntegerCache.low = -128 IntegerCache.high = 127

的值IntegerCache.cache[i + (-IntegerCache.low)]最终IntegerCache.cache[129]应该1在整数缓存索引 [129] 处有值,但是当我调试代码时,我3在索引 [129] 处找到了值:

由于 IntegerCache 是最终类型,因此不应在索引 [129] 和 [131] 处重复值,例如 3

所以,我最终例外:

我的问题是这怎么可能?请建议

0 投票
1 回答
58 浏览

sql-server - Ibatis 以数组形式检查属性

我使用 Ibatis 1.6 版

我知道 ibatis 可以从数组参数中读取值。这是我的代码

但我需要先检查值,如果它是空的。

但是当我这样做时,我得到了一个错误。

缺少对象或列名称或为空。对于 SELECT INTO 语句,验证每一列都有一个名称。对于其他语句,请查找空别名。不允许使用定义为 "" 或 [] 的别名。将别名更改为有效名称。

我怎样才能做到这一点?由于某些原因,我必须使用数组作为该查询的参数。可能吗?

请我在这里需要一些帮助好人。