问题标签 [mybatis]

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 投票
5 回答
23121 浏览

java - 在 MyBatis 中处理非常大量的数据

我的目标实际上是将数据库的所有数据转储到 XML 文件中。数据库不是很大,大约300MB。问题是我的内存限制只有 256MB(在 JVM 中)。所以很明显我不能把所有的东西都读入内存。

我设法使用 iBatis(是的,我的意思是 iBatis,而不是 myBatis)通过getList(... int skip, int max)多次调用它来解决这个问题,并增加skip. 这确实解决了我的记忆问题,但我对速度并不满意。变量名称表明该方法在后台执行的操作是读取整个结果集,然后跳过指定的记录。这对我来说听起来很多余(我并不是说这就是方法正在做的事情,我只是根据变量名猜测)。

现在,我为我的应用程序的下一个版本切换到 myBatis 3。我的问题是:有没有更好的方法在 myBatis 中逐块处理大量数据?无论如何要让 myBatis 处理前 N 条记录,将它们返回给调用者,同时保持结果集连接打开,这样下次用户调用 getList(...) 时,它将开始从 N+1 记录读取而不做任何事情“跳过”?

0 投票
4 回答
17311 浏览

ibatis - Ibatis/MyBatis 动态选择,无需创建任何 Pojo/Mapper

有没有办法使用 Ibatis/MyBatis 动态选择/更新/删除?

当我说“动态”时,这意味着我根本不想创建任何 POJO/DataMapper。

欢迎任何 URL 示例。

0 投票
5 回答
14535 浏览

hibernate - 对于使用带有 JDBCTemplates、iBatis/myBatis 或 Hibernate 的 Spring 的新项目?

您好,我们正在启动一个项目,我们必须在使用 Spring JDBCTemplates、iBatis/myBatis 或 Hibernate 作为我们的持久层之间做出决定。我或多或少熟悉他们两个的概念,但我想知道人们目前倾向于使用什么。

我的要求是:

  • 让一切尽可能简单
  • 易于学习和使用
  • 高性能
  • 最佳开发人员生产力
  • 必须与 Spring 3 一起使用

如前所述,我们希望一切都尽可能简单。我的偏好倾向于 iBatis/myBatis,因为它看起来更易于使用,而且我们不需要真正的 OR Mapper。但我真的很期待向使用这些框架的人学习。

0 投票
1 回答
370 浏览

jquery - Using Jquery ajax() call, Tomcat logs fall silent

I am trying to avoid a whole bunch of manual inspection to debug my code, even though the error will most likely turn out to be a mistype or something silly like that. I am making an ajax() call to a Struts 2 action using jQuery and the execution is halted. At the Javascript level, I get the very descriptive 500 error indicating "No clue, you are on your own developer". So what I am doing at the action level in Struts2 is putting a log.info line after every command. Here is what I have for demonstration purposes:

My tomcat logs give me:

This indicates that the call to my Struts 2 service, deleteNote which actually does a soft delete (an update statement) through myBatis, is where the problem is. However, the apparent failure is silent. Usually when I make a mistake with myBatis, myBatis lets me know (and the logs are often very useful) and I go about my way fixing my mistake. I have myBatis set at the INFO level.

So what is it that is shutting up Tomcat? Not only for this occasion, but also for future ajax() calls where I need to debug, how do I go about getting more information from Tomcat/Log4J?

0 投票
1 回答
129 浏览

java - Adding where clauses from database

We are using MyBatis 3.0.3 & Spring 3.0.5 in our project.

We are trying to implement data level security through a table which stores where clauses (userid < 200, active == true, ...).

So, the problem comes when we want to add a clause to a select query dinamically in execution time.

We are thinking about the possibility of using Spring AOP but we are not sure if it is possible or not, if it is a good solution and appart from that we don't know how to implement it.

Please share your thoughts.

Thanks in advance,

Silvia.

0 投票
2 回答
23145 浏览

orm - 如何在 MyBatis 中使用带注解的动态 SQL 查询(如何使用 selectProvider)?

我试图避免在 mybatis3 中使用额外的 xml 来定义映射器。注释正好适合。

我对@SelectProvider/@InsertProvider/etc 的使用有点困惑。不要以为网上有很多资源可以指导我。

基本上,我想在mybatis3中找到alternative for的注解版本。

例如,我有一个 xml 映射器,我想将其转换为使用注释

谁能提供包括代码在内的具体答案/解决方案?

提前致谢!

0 投票
2 回答
3072 浏览

java - 使用 MyBatis 从 DB2 获取生成的密钥

我有一个使用自动生成的列生成的表,但我无法使用 MyBatis 检索 ID。我已经通过测试证明 SQL 正在工作并且正在插入行,但我无法生成 ID。

XML 配置为:

XML_LOG_T 上有一个列 REQ_ID,它是自动生成的。我的映射器界面是:

返回的总是 1,我相信这是插入的记录数。我确定我遗漏了一些明显的东西,但看不到树木的树木。

0 投票
3 回答
31541 浏览

hibernate - 如何配置 Spring 使 JPA(Hibernate)和 JDBC(JdbcTemplate 或 MyBatis)共享同一个事务

我有一个数据源,我使用 Spring 3.0.3、Hibernate 3.5.1 作为 JPA 提供程序,我使用 MyBatis 3.0.2 进行一些查询,我的应用程序在 Tomcat 6 上运行。当我同时调用两者时,我有一个 HibernateDAO 和一个 MyBatisDAO从用@Transactional 注释的相同方法看起来它们不共享相同的事务,它们获得不同的连接。
我怎样才能让他们这样做?

我尝试从 DataSourceUtils.getConnection(dataSource) 获取连接,我得到了 MyBatis 使用的连接,这很奇怪,我认为问题出在 MyBatis 配置中,它不能使用 JpaTransactionManager。即使多次调用 DataSoruceUtils.getConnection 总是提供相同的连接,这没关系。

经过一番谷歌搜索后,我尝试了 spring-instrument-tomcat 的类加载器(虽然我不知道 tomcat 是否真的使用它:))

部分应用上下文

部分 mybatis 配置

部分持久性.xml

0 投票
2 回答
1140 浏览

oracle - 如何将 Oracle 的行级安全性与 MyBatis 集成?

我正在从事的一个项目使用具有行级安全性的 Oracle 数据库。call DBMS_APPLICATION_INFO.SET_CLIENT_INFO('userId');在执行任何其他 SQL 语句之前,我需要能够调用。我试图找出一种在 MyBatis 中实现这一点的方法。我有几个想法,但无法实现,包括以下内容:

尝试 1

但是,您不能在单个 JDBC 调用中使用两条语句,而且 MyBatis 不支持 JDBC 批处理语句,或者至少我找不到。

尝试 2

但是,这就是我所得到的,因为我了解到您不能在过程中返回数据,只能在函数中返回,因此无法返回数据。

尝试 3

我考虑过创建一个简单的 MyBatis 语句来设置客户端信息,并且需要在执行语句之前调用它。这似乎是最有希望的,但是,我们正在使用 Spring 和数据库连接池,我担心竞争条件。我想确保客户端信息不会溢出并影响其他语句,因为连接不会关闭,它们会被重用。

软件/框架版本信息

Oracle 10g
MyBatis 3.0.5
Spring 3.0.5

更新
忘了提我也在使用 MyBatis Spring 1.0.1

0 投票
1 回答
255 浏览

spring - 使用 Spring,MyBatis 作为客户端服务器模型

根据我之前的帖子,我能够为我的应用程序构建多线程服务器客户端模型。

现在我必须将它迁移到 Spring(到目前为止,Core 不是 MVC)。有人可以再次建议从哪里开始吗?

谷歌了很多,但找不到像样的教程。如果有人可以提供帮助。提前致谢。