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,268
questions
0
votes
0
answers
7
views
How to use MyBatis to map MSSql Time to Java LocalTime type
I am having DB chema with Time type:
[localTime] [TIME],
I am having a POJO with field
LocalTime localTime;
Now, I am using mybatis to map checkout_time to LocalTime localTime using:
<result ...
0
votes
0
answers
27
views
myBatis: ### Error querying database. Cause: java.lang.UnsupportedOperationException
I stuck in a problem with following while using myBatis.
2022-06-28 18:31:18,906 DEBUG [task-2 ]
c.b.c.r.StoreDAO : ###### params StoreSearchParam(uid=null,
latitude=127.044093,...
0
votes
0
answers
18
views
MyBatis jQuery Conflicts Error - Uncaught TypeError: Cannot read properties of null (reading 'id')
We migrated to MyBatis 3.5.10, MyBatis-Spring 2.0.7, Spring 5.3.19, jQuery 3.4.1 and jQuery-jqGrid 4.4.1. But it is giving the following error. Please note that this error exists with any version of ...
0
votes
1
answer
59
views
Mybatis not handling ZonedDateTime
I have columns in a database table of type DATE which I'd like mybatis to convert to java.time.ZonedDateTime but it seems that the built in ZonedDateTimeHandler is not working. I get the following ...
0
votes
0
answers
32
views
How to get all SQL statements through SqlSessionFactory
The version of mybatis I am using is 3.4.6. I want to get all the SQL statements through SqlSessionFactory. How can I do this?
0
votes
1
answer
53
views
How to improve mybatis-3's mvn running performance?
I'm trying to run mvn site for mybatis-3, but the build time is take really long time. I even tried to run mvn site once, then run mvn site again on the same machine. The second time still took almost ...
1
vote
0
answers
53
views
How can I use a parameter more than once in Mybatis
I want to use some parameter for more than once, the method in interface like this:
List<PoliceCompanyJointCheck> selectJointCheckPageRedList(@Param("pageModel") PageModel<...
1
vote
0
answers
24
views
How to suppress auto statement flushing in MyBatis
Background
I want to implement the following procedure with Spring and MyBatis:
Read a line from a CSV file
Query a table (table ACCOUNT) with values read from the CSV file.
Merge the values from the ...
0
votes
1
answer
14
views
MyBatis mapping nest pojo of fundamental type
I have a POJO of type:
POJO {
int id;
int name;
List<Date> Dates;
}
Now my POJO is broken into two tables x and y, where y have dates and x have name, which are joined over the id as below:
...
0
votes
0
answers
26
views
How to migrate join queries from Hibernate Criteria to MyBatis
I'm migrating some queries from a module with Hibernate to another with MyBatis. The first module performs some queries using the Criteria API.
My model is something like:
public class SomeEntity {
...
-1
votes
1
answer
71
views
How can I replace nested for statement with mysql query?
Environment :
MySQL 5.7.x
Spring MVC
Table Data (name: TableA)
seq
level
name
order
parent_seq
1
1
name1
1
0
2
1
name2
2
0
3
2
sub1-1
1
1
4
2
sub1-2
2
1
5
2
sub2-1
1
2
6
3
third-2-1
1
5
7
3
...
0
votes
0
answers
27
views
How can I use a variable inside an attribute's value?
How can I use a variable inside an attribute's value?
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "...
0
votes
0
answers
37
views
Using java method returned string as sql in mapper file [duplicate]
I am using Mybatis framework. We have java method which does some condition checks, prepares and returns the final dynamic sql query. How to configure/tell Mybatis to use the java method returned ...
0
votes
0
answers
28
views
Why My SpringBoot Project use Mybatis have mybatis wroing with differnet platform environment
My project is SpringBoot+Mybatis。I runing it on the windows is Ok,but when it run on the docker (centos),it run the wrong as follows as. It seems can't receive the parameter.
2022/05/27 17:30:57.188 [...
0
votes
0
answers
32
views
Under what circumstances will a class be added to the singleton pool of spring/spring boot
We always use the bean and bean factory, but how can we add a class as a bean to the singleton pool automatic?
For example, when i startup a application, i can use @Resource to get my mapper class ...
0
votes
0
answers
82
views
nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'query' in
I have a problem when I am doing an interface test
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException
I want to ask if these two files need ...
0
votes
0
answers
18
views
Is it possible to distinguish between data not found and columns is null in mybatis/hibernate
Is it possible to distinguish between data not found and columns is null in mybatis/hibernate?
Table:
example {
id,
string,
date,
number,
...
}
SQL:
select string,date,number from example ...
0
votes
1
answer
52
views
Getting error while iterating Map in mybatis
Getting this error while iterating over Map in mybatis
Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_key_0', mode=IN, javaType=...
0
votes
0
answers
25
views
Mybatis update batch, SQL statement missing single quotes when a field contains a string with parentheses
mybatis xml like this
update ${tableName}
<trim prefix="set" suffixOverrides=",">
<trim prefix="name =case id" suffix="end,">
...
0
votes
0
answers
28
views
Why performance of splicing update sql is better than using batch executor?
The row of table is 20 millions, the row of waiting to update is 10k. Splicing update SQL like that UPDATE xx SET a = x WHERE id = x;UPDATE xx SET a = x WHERE id = x;UPDATE xx SET a = x WHERE id = x; (...
1
vote
0
answers
36
views
how to convert setter to List when the parameter is not list?
The reason for not using List<Integer> purchase_item_cart because of problem in mybatis mapping and the solution i can think of is convert it to List
@Data
@NoArgsConstructor
@AllArgsConstructor
...
0
votes
0
answers
30
views
how to insert query for annotation insert with parameter list in mybatis?
I able to insert data if without list parameter but i need it.
Can any know how to do it using mybatis annotation @Insert with list Parameter?
//purchase_item_cart error since its list
@Insert(&...
0
votes
1
answer
61
views
how to insert query in mybatis with parameter list?
Can any one convert the Sample i found in https://localcoder.org/mybatis-insert-list-values solution 3. There is no explanation what happen and im having hard time to change it like the sample and Im ...
0
votes
0
answers
18
views
MyBatis @SelectProvider instantiates a new Object of the provider class losing inception advantages
I'm running a springboot application with MyBatis support:
I need to use the SelectProvider annotation on DAOs to access some query.
@SelectProvider(type = QueryProvider.class, method = "...
0
votes
0
answers
37
views
How does the supplier.get() function assign list value to the PageInfo object when there is no variable defined to capture supplier.get() value?
The following code is in working state but I don't get it how supplier.get() value is being assigned to PageInfo object which is later being retrieved in the code stated after function ...
0
votes
1
answer
31
views
How to make null must error if input is empty in mybatis?
Im trying to insert empty data and it must error but its still saving.
I try try/cath and if statement if null and still not working.
Can anyone suggest how to do it?
Output in this image RPCbloom
...
0
votes
0
answers
26
views
How to print a list of posts created by a user
I want to print list posts created by users.
like this => enter image description here (Forced the user_name in .xml)
I have already implemented login and pass the session value as well.
But, I ...
2
votes
0
answers
48
views
a performace issue of mybatis 3.5.3
My team meet a performance issue of mybatis 3.5.3, execute a simple select from mysql which takes about 15 seconds. The result of this query is a List, and the count of the list is 150. The mapper is ...
0
votes
1
answer
49
views
Mybatis foreach mapper item exception
I am using foreach for SELECT IN clause.
Item has not been found by mapper.
Here is part of exception.
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding....
0
votes
0
answers
36
views
Mapping of JDBC connection string parameters to MyBatis properties
I am using mybatis-guice (MyBatisModule) to connect the Java application with the PostgreSQL database.
The connection parameters are sent to MyBatis as named properties (see an example here: https://...
0
votes
0
answers
41
views
MyBatis - jar packed in war
I'm trying to run application with MyBatis on Tomcat 9, but I get an error:
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for cz.pse.agata.commons.dto.mapper....
0
votes
0
answers
15
views
Mybatis Cache attribute access
<cache type="com.domain.something.MyCustomCache" flushInterval="60000" size="512" readOnly="true"/>
How can I get the "flushInterval" value in ...
0
votes
1
answer
31
views
Mybatis, pass muliple list as parametres
String loadCandies(@Param("id") String id, @Param("varietyList") List varietyList, @Param("errorCode") List errorCodes)
How can I achieve this in mybatis xml, as for a ...
1
vote
2
answers
94
views
Why are singleton beans created twice in Spring?
I have a spring-boot project that contains a BookMapper bean:
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BookMapper {
// some CRUD methods here...
}
The bean is ...
0
votes
0
answers
23
views
Why sql wrapped with script tag?
Source code from Mybatis Plus 1.1.
I can not understand that why some sql statements wrapped with a script tag.
Why use the script tag? And what's the function of the script tag?
public enum SqlMethod ...
0
votes
1
answer
66
views
Mapping values in nested object in myBatis?
I want to map a nested object with one select query.
For example:
// parent class
public class Parent {
private String name;
private Child child;
}
// child class
public class Child {
...
0
votes
0
answers
17
views
how can i use Mybatis selectKet funtionality in Node.js?
how can i use Mybatis selectKet funtionality in Node.js?
I wanted to use selectKey in xml file but it never works!
they just say "consider using Cdata"
but it's quite hard to find the way of ...
0
votes
0
answers
79
views
Java Mybatis to Python SQL Alchemy - is there resultMap mybatis equivalent in SQLAlchemy python. which logically maps join queries removing duplicates
Say we have a select query like
select a.col1,a.col2,a.col3,b.col1,b,col2,c.col1
from a, b, c
where a.col1(+)=b.col2 and b.col3(+)=c.col2
In mybatis xml we have mapper defined which could include ...
0
votes
1
answer
145
views
Spring boot & MyBatis xml query for update list
I try to update a column my Mybatis xml Mapper.
The parameterType is Request class, and it contained List type object.
I want to get that object from class to xml mapper.
But I got an issue like this ...
1
vote
0
answers
36
views
After I apply intellij-code-formatter.xml, the xml indent fommated as strange form
env: spring boot 2.6, mybatis, intelliJ
I apply formatter xml.
but I use ctrl + alt + l (window) formatting short cut
then mybatis.xml formatted like below,
which tag can fix this (normal format)? ...
0
votes
0
answers
123
views
Mybatis map collection to HashMap
I'm rather new to MyBatis. There's theFoo which could have many Bars, and the Bar has fooId as FK. I want to query for all Foos with its associated Bars.
Here are my domain objects:
public class Foo {
...
0
votes
0
answers
34
views
Does Mybatis support neo4j cypher?
MATCH (n:#{name})-[r]->(m:#{name}) RETURN n.name as sn,r.name as rn,m.name as tn
It seems like #{} is not working here, I use ${} instead and it worked
print error sql
MATCH (n:$1)-[r]->(m:$2) ...
0
votes
1
answer
77
views
java.lang.ClassNotFoundException: com.google.inject.AbstractModule not found by org.mybatis.mybatis-guice
There is a problem that the bundle using mybatis-guice library using the felix framework fails to start.
The running environment is java11 and karaf 4.2.14 versions.
This is the corresponding error ...
1
vote
0
answers
59
views
Mybatis and PostgreSQL although the rows are deleted, multiple delete statements return 0
as the title says, when I execute multiple delete statements with a single Mybatis Delete annotation, it returns 0 rows. However, when I delete them separately, they both return the number of rows ...
0
votes
1
answer
18
views
java.sql.SQLSyntaxErrorException in mybatis
The phenomenon and background of the problem encountered
Problems encountered when configuring mybatis and writing tests, an error will be reported as soon as you click to run
problem related code,
@...
1
vote
0
answers
82
views
Return id from MyBatis @Insert for immutable object
I have an immutable object Card:
public record Card(int id, int deck_id, int count, String name) {}
And a mapper file with an insert statement:
@Mapper
public interface DeckMapper {
@Insert(value ...
0
votes
1
answer
23
views
The attribute id is undefined for the annotation type Results using Mybatis
I am trying to do this :
@Select("SELECT * FROM DGE_ADJUSTMENTS WHERE COD_ADJUSTMENT = #{id}")
@Results(id = "resultadoId", value = {
But The attribute id is undefined for the ...
-2
votes
3
answers
391
views
NULL Pointer Exception in Spring Controller
I am learning backend with Java and I am new to Spring, ORM, template engines, and all these things. I use Spring with Mybatis, H2, and Thymeleaf. I use IntelliJ IDEA if it matters. In my home ...
0
votes
3
answers
87
views
How to select both sum value of all rows and values in some specific rows?
I have a record table and its comment table, like:
| commentId | relatedRecordId | isRead |
|-----------+-----------------+--------|
| 1 | 1 | TRUE |
| 2 | 1 ...
0
votes
0
answers
42
views
CustomInterceptor to intercept @UpdateProvider linked method,but execute twice
I defined an interceptor to intercept the update method.The method body only prints the intercepted SQL.
The SQL is constructed through the buildupdatesql () method in @ updateprovider and internally ...