Questions tagged [mybatis]
MyBatis is a framework for mapping objects to relational databases with an emphasis on high performance and simplicity. XML descriptors or annotations couple the objects to SQL statements or stored procedures.
3,039
questions
0
votes
0answers
20 views
MyBatis is giving nullpointer exception when using isInCaseInsensitiveWhenPresent
As per MyBatis document here https://mybatis.org/mybatis-dynamic-sql/docs/conditions.html
IsInCaseInsensitiveWhenPresent should not render if a null value is passed.
So, below is my query:
...
0
votes
1answer
20 views
Retrieving a list of values across databases with mybatis
I have 2 Java POJO files
class Filter Variables {
private String id;
private String name;
private List<ValueVariables> variableValues;
getters() setters()
}
class ValueVariables {
private ...
0
votes
0answers
22 views
How can three double quotes ''' work in a mybatis @Insert annotated block?
I want to use three double quotes """ in a mybatis @Insert annotated block
but IDEA shows there are errors, it says java 8 doesn't support this, but previously I remember in another ...
1
vote
0answers
37 views
Database OUT Parameter doesn't return any data on Java side
I'm fetching data from a package that has a stored proc. The proc has 2 input parameters (Number and Varchar2) and an output parameter (Custom type). When I try to connect to the package and get data ...
0
votes
1answer
21 views
Mybatis query returns an empty set
The result of SQL query is empty,However, the length of the list in the encapsulation result is 1.
And the element in the list is null,So What shall I do?
0
votes
2answers
32 views
nested exception is org.postgresql.util.PSQLException: ERROR: relation “equ_config” does not exist
I'm developing a backend program with springboot + mybatis + Yugabyte.
It works well in the development environment, but got following errors in online environment :
2021-04-14 13:52:15.123 [http-nio-...
0
votes
0answers
29 views
Mybatis ORA-00911: invalid character
The error message goes like this below.
The error may exist in mappers/admin-mapper.xml
The error may involve defaultParameterMap
The error occurred while setting parameters
Cause: java.sql....
0
votes
0answers
25 views
How can I create a table using Mybatis and SQLite?
I am trying to create a new database and new table using Mybatis and SQLite. I found from previous answers (1, 2, 3) that Mybatis does support using CREATE and ALTER statements, by marking them as &...
0
votes
1answer
33 views
Multiple selection from different tables in one query
My question is about optimizing queries with mybatis.
List<SomeObject> someObjectList = oracleMapper.getAllSomeObject();
in my project I have to unload data from one database and make a request ...
1
vote
1answer
39 views
Is it possible to convert CLOB data to String in Mybatis sql mapper xml?
I want to receive CLOB data of CONTENT column as java.lang.String value with only sql mapper definition.
Select query is something like this.
<select id="selectById">
<![...
0
votes
1answer
40 views
Return rows only if count of them is bigger than 10
I have two requests:
select count(*) <![CDATA[ > ]]> #{count} from bundle where updated_at <![CDATA[ > ]]> #{updatedAt}
select * from bundle where updated_at <![CDATA[ > ]]> ...
0
votes
0answers
37 views
Is there any Auto trim way available after getting results back from Database in spring
I am using Spring-Boot with MyBatis, with MSSQL server database.
There is no hold for me as such since data exist in column with lot of pre and post spaces. I can nothing do with data.
What I wants is ...
0
votes
0answers
67 views
DB2 Current Schema replaced on the fly
hope you can help me with an weird issue I'm facing in a project.
I'm running over a Java app that is currently running with Eureka, MyBatis, DB2 as database & Druid datasource.
We have a DB2 URI ...
0
votes
0answers
26 views
Can I Overwrite **Mapper.xml On My Applications?
When I use Mybatis 3.4.2 and spring boot。
I found that when I write **Mapper.xml on my business jars, But Others want to overwrite my **Mapper.xml on there spring boot applications, but they can't do ...
1
vote
1answer
44 views
@TransactionalEventListener how to bind TransactionManager [duplicate]
There are multiple data sources in my project, and each data source corresponds to a transaction manager, and they share a single aspect. Now there is a problem in my project: some logic needs to be ...
0
votes
0answers
29 views
Primary/Secondary failover DataSource in Spring
I have a java web application developed on Spring framework which uses mybatis. I see that the datasource is defined in beans.xml. Now I want to add a secondary data source too as a backup. For e.g, ...
0
votes
0answers
25 views
MyBatis return hard
Hey guys I am new to MyBatis. Now trying to solve the following problem:
The current implementation is:
Store procedure(sp_Name): returning sp_out_1, sp_out_2 into ResultPOJO
public class ...
1
vote
2answers
29 views
Mybatis mix prepared statement with sql injection
I have a query that I'd like Mybatis to treat as a sql injection for part of it an also as a prepared statement. I am using Mybatis xml files rather than annotations. Here is what I'm trying to do...
...
1
vote
0answers
24 views
mybatis: update one table accoring to another table
I want to acheive:
When I click the page, it will update one column in the table 'staffinfo' and then show the table.
and I want to update the column named 'lengthofworking' in table 'staffinfo'. and ...
1
vote
0answers
30 views
How to mock (simulate) MyBatis-Plus data access layer for unit testing for Model<> Active Record?
In codebase where model classes use Model from https://github.com/baomidou/mybatis-plus
public class SomeDomainClass extends Model<SomeDomainClass> {
How to mock (simulate) MyBatis-Plus data ...
0
votes
0answers
22 views
Does mybatis support check property exist?
I want to dynamically construct sql with different concrete subclass
List<CommonDO> commonQuery(AbstractQuery query)
but if property not exists it will throw exception like below
Caused by: org....
0
votes
1answer
19 views
SqlSessionTemplate is not serializable in flink
My flink aplication throws such exception when it starts:
Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: org.apache.ibatis.binding.MapperProxy@3fe8ad3f is ...
0
votes
1answer
35 views
How to insert and return the uuid?
My goal is to insert into a table
CREATE TABLE event_info (
id INT NOT NULL AUTO_INCREMENT,
uuid VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE (uuid)
);
@Mapper
public class EventMapper {
...
0
votes
0answers
17 views
update&select in on transaction ,can't get the data
background:
sprintboot + mysql5.7 + mybatis
repeatable read
i thought i can select the data which insert in one transcation.but the answer is no.
@Transactionnal
public void test(){
...
0
votes
1answer
36 views
Integration testing with MyBatis, H2 and Oracle procedures
I have a stored Oracle procedure that I call like so:
CALL MY_PROC(
p_arg => #{arg, jdbcType=INTEGER, mode=IN},
p_var => #{var, jdbcType=VARCHAR, mode=IN},
...
2
votes
1answer
32 views
Mybatis get clob field
We want to get a clob field in a annotation based call to a oracle function. This function return a CLOB field Oracle.
We have this code:
@Select("{ #{result, javaType=java.lang.String ,...
0
votes
0answers
25 views
the difference between Reflector.getParameterTypes().length and ~.getParameterCount
why does Mybatis use the former instead of the rest?
Arrays.stream(constructors)
.filter(constructor -> constructor.getParameterTypes().length == 0)
.findAny()
.ifPresent(...
0
votes
0answers
23 views
How to make custom type handler available globally for specific datatype in mybatis
I am using Mybatis 3.2.2. While inserting data dynamically in Oracle I am facing an issue with Timestamp datatype. So I have written custom type handler for TimeStamp.
Now for any query whenever ...
1
vote
0answers
33 views
Can I “autowire” Spring Boot components to MyBatis queries?
For an example, here is a sample query:
<select id="selectCouponCodes" resultType="SomeDao">
select *
from temp_table
where code = #{code}
</select>
Normally, I ...
0
votes
3answers
49 views
Springboot application can't run without execute the 'mvn clean' command
Hi, recently I encountered a very wired problem in my springboot application. When I tried to run my application, it can't run. However, after I execute 'mvn clean' command, it can run successfully. ...
2
votes
1answer
70 views
How to deal with MyBatis in WebFlux stack
I have a huge enterprise java application wtitten with "ye olde good" stack of technologies: Spring Web MVC, PostgreSQL, MyBatis. Let's assume there is a real need to migrate the application ...
0
votes
0answers
28 views
my mybatis not work for Oracle but tested it work in SQLDeveloper
I'm new to Mybatis, I create a mapper to get the timestamp I want. but only one period of time it works, but later it just returns null. and for another function, I using SimpleDateFormat to format ...
0
votes
0answers
28 views
Select by ResultHandler will put a empty list objcet in localCache
MyBatis version
3.5.4
Database vendor and version
MySQL 5.7.14
Test case or example project
public static final String URL = "jdbc:mysql://localhost:3306/myTest?useUnicode=true&...
1
vote
0answers
38 views
How to get List<String> inside of a POJO with MyBatis Mapper?
My goal is to fill the UserDto POJO using the 'UsersMapper' MyBatis Mapper.
public class UserDto {
private String username;
private String password;
private List<String> authorities;
...
0
votes
0answers
23 views
MyBatis How to use foreach in select statement?
arraylist = [a, b]
SELECT
<foreach statement>
${list}
</foreach>
FROM DUAL
result : select a, b from dual
How to use foreach in select statement?
1
vote
1answer
71 views
snowflake temp table connection using JDBC
I am trying to put temp values in the snowflake temporary table using Mybatis. Connection details configured at WebSphere Application server's server.xml file.
Ideally values should be retained at ...
2
votes
0answers
44 views
End the transaction by performing findById using spring boot and myBatis
I think it is bad practice, but I would like to know your reasons why it is.
@Transactional
public Person update(Person person, Person updated) {
personMapper.update(updated);
...
1
vote
0answers
22 views
@Transaction annotation not working with Global transactions but it is working for Local transactions
We have used class level @transaction annotations to enable rollback mechanism in Spring batch.
The code is given below:
@Transactional(rollbackFor = { DaoException.class, LogicRuntimeException.class }...
2
votes
1answer
55 views
Mybatis Insert PK manually
I am trying to single insert data into table with assigned PK. Manually assiging PK.
XML file
<insert id = "insertStd" parameterType = "com.org.springboot.dao.StudentEntity" ...
1
vote
1answer
49 views
com.ibm.websphere.ce.cm.StaleConnectionException: IO Error: Connection reset while upserting a record with PDF on an OracleDb
We have a Java back-end, powered by Spring 3.2.17, which is deployed inside a WebSphere Liberty Application Server which belongs to the customer, so I don't have access to it.
We're trying to create ...
0
votes
2answers
41 views
How to do bulk insert in mybatis where we want to iterate over List of Map in Oracle
I am using INSERT statement with SELECT UNION ALL for bulk insert in Orcle MyBatis.
My issue is I want to make this query as runtime query where column name and data to be inserted is taken from List.
...
1
vote
1answer
59 views
MyBatis SQL parsing
In our AWR report we saw some "select * from TABLE" sql with high number of parses but 0 executions. Can someone please help me why these statements gets parsed. We do not have this SQL ...
0
votes
1answer
36 views
Mybatis association in one-one in model but one-many in database : No crash?
We noticed something a bit wrong with MyBatis.
Let's say I have this :
class Player {
String id;
Account account;
}
class Account {
String id;
Integer money;
}
And resulting MyBatis ...
0
votes
0answers
39 views
When I use mybatis cursor and druid , I got an exception “java.sql.SQLException: No operations allowed after statement closed”
Why use ResultSet.close in DefaultCursor.Iterator.hasNext, when I use mybatis cursor and druid, I got an exception "java.sql.SQLException: No operations allowed after statement closed".
...
2
votes
1answer
92 views
java.lang.IllegalArgumentException: Result Maps collection does not contain value for a certain mapper
I'm developing an application using MyBatis and I'm facing a real strange problem.
This already happened a few days ago but by uncommenting the following property on the dao-context2.xml I was able ...
0
votes
1answer
29 views
How to use Array in spring boot mybatis annotation?
I received an array of columns from Frontend. I need SELECT ---- WHERE [Received Array] = 1. However, the length of the array is dynamic.
That is, a query with a value of 1 should be written for each ...
0
votes
1answer
26 views
Mybatis XML - Specify table name in keyColumn attribute
I am using spring boot and myBatis XML mapper to perform multiple inserts into different tables. I need the autogenerated id from one of the inserts. How do I either specify a table name in the ...
0
votes
2answers
23 views
returning a created ID from Oracle database using java Spring
For example I can use the POST method to send some JSON to the web service and then create an object. Is it best practice to then set the HTTP status to created (201) or ok (200) and simply return a ...
0
votes
0answers
22 views
Mybatis always return null value to the last column on select list
I'm using mybatis to query data from mysql, I have one sql like below:
select t1.a , t1.b , t2.c, (select d from C t3 where t1.e=t3.e limit 1) as d
from A t1 left join B t2 on t1.x = t2.x
where ...
...
0
votes
0answers
24 views
myBatis-plus error:NoClassDefFoundError: org/mybatis/logging/LoggerFactory
current version
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>...