Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Do Nhu Vy
@donhuvy
hello
I generate by MyBatis generator

```package com.donhuvy.model;

import java.io.Serializable;
import java.math.BigDecimal;

public class Ccy implements Serializable {
private Long currencyId;

private Object currencyName;

private BigDecimal exchangeRate;

private Short exchangeRateOperator;

private Short isActive;

private Object caAccount;

private Object baAccount;

private Object prefix;

private Object ccyName;

private Object decimalSeperate;

private Object afterDecimal;

private Object subfix;

private BigDecimal convertRate;

private Object prefixEng;

private Object ccyNameEng;

private Object decimalSeperateEng;

private Object afterDecimalEng;

private Object subfixEng;

private BigDecimal convertRateEng;

private Object prefixDefault;

private Object ccyNameDefault;

private Object decimalSeperateDefault;

private Object afterDecimalDefault;

private Object subfixDefault;

private BigDecimal convertRateDefault;

private Object prefixDefaultEng;

private Object ccyNameDefaultEng;

private Object decimalSeperateDefaultEng;

private Object afterDecimalDefaultEng;

private Object subfixDefaultEng;

private BigDecimal convertRateDefaultEng;

private BigDecimal exampleAmount;

private BigDecimal sortOrder;

private String valueOfMoney;

private Object createdDate;

private Object createdBy;

private Object modifiedDate;

private Object modifiedBy;

private static final long serialVersionUID = 1L;

public Long getCurrencyId() {
    return currencyId;
}

public void setCurrencyId(Long currencyId) {
    this.currencyId = currencyId;
}

public Object getCurrencyName() {
    return currencyName;
}

public void setCurrencyName(Object currencyName) {
    this.currencyName = currencyName;
}

public BigDecimal getExchangeRate() {
    return exchangeRate;
}

public void setExchangeRate(BigDecimal exchangeRate) {
    this.exchangeRate = exchangeRate;
}

public Short getExchangeRateOperator() {
    return exchangeRateOperator;
}

public void setExchangeRateOperator(Short exchangeRateOperator) {
    this.exchangeRateOperator = exchangeRateOperator;
}

public Short getIsActive() {
    return isActive;
}

public void setIsActive(Short isActive) {
    this.isActive = isActive;
}

public Object getCaAccount() {
    return caAccount;
}

public void setCaAccount(Object caAccount) {
    this.caAccount = caAccount;
}

public Object getBaAccount() {
    return baAccount;
}

public void setBaAccount(Object baAccount) {
    this.baAccount = baAccount;
}

public Object getPrefix() {
    return prefix;
}

public void setPrefix(Object prefix) {
    this.prefix = prefix;
}

public Object getCcyName() {
    return ccyName;
}

public void setCcyName(Object ccyName) {
    this.ccyName = ccyName;
}

public Object getDecimalSeperate() {
    return decimalSeperate;
}

public void setDecimalSeperate(Object decimalSeperate) {
    this.decimalSeperate = decimalSeperate;
}

public Object getAfterDecimal() {
    return afterDecimal;
}

public void setAfterDecimal(Object afterDecimal) {
    this.afterDecimal = afterDecimal;
}

public Object getSubfix() {
    return subfix;
}

public void setSubfix(Object subfix) {
    this.subfix = subfix;
}

public BigDecimal getConvertRate() {
    return convertRate;
}

public void setConvertRate(BigDecimal convertRate) {
    this.convertRate = convertRate;
}

public Object getPrefixEng() {
    return prefixEng;
}

public void setPrefixEng(Object prefixEng) {
    this.prefixEng = prefixEng;
}

public Object getCcyNameEng() {
    return ccyNameEng;
}

public void setCcyNameEng(Object ccyNameEng) {
    this.ccyNameEng = ccyNameEng;
}

```

but private Object caAccount;
I hope it is private String caAccount;
I don't know how to config
Liuzh
@abel533
@donhuvy<table> 元素内配置列的类型。
Andrija Kovačević
@jddipqd_twitter
Hi
Does anyone know if it is possible to use bind inside a foreach loop?
I have something like this
<bind name="keywordList" value="params.keyword.split(' OR ')" />
<foreach collection="keywordList" item="keywordSingle" open="AND (" close=")" separator=" OR ">
    <bind name="keywordLike" value="'%' + keywordSingle + '%'" />
    (
        p.name LIKE #{keywordLike}
        OR p.internal_id LIKE #{keywordLike}
        OR p.sku LIKE #{keywordLike}
    )
</foreach>
Andrija Kovačević
@jddipqd_twitter
However, the bind inside foreach doesn't seem to work properly, as in the generated query I only get the last element of the splitted array
Am I doing something wrong or this is not possible?
Liuzh
@abel533
@jddipqd_twitter Because your bind name is the same
Brandon
@JavaMonkey_twitter
I am currently working in a code base where our DAO layer is implemented using mybatis mapper interfaces using the mapper annotations to define the SQL interactions. I have a general DAO interface that I need to implemented with mybatis. How is that done? Can someone point me to documentation or an example of a concrete mapper that implements a generalized interaface?
Liuzh
@abel533
@JavaMonkey_twitter in mybatis 3.5.4+, ProviderSqlSource add a additional parameter ProviderContext.if you want a common dao, have a look at https://github.com/abel533/Mapper.
bhshawon
@bhshawon
Hi guys, is the list of supported databases documented anywhere?
474846718
@474846718
@abel533 大佬请问通用mapper好用还是 mybatis plus好用?
mp已经升级到java 8了
1254042329
@1254042329

The error may involve com.example.zfproj.wechat.dao.WeChatClassificationMapper.selectByExample-Inline

The error occurred while setting parameters

SQL: select ID, CODE, NAME, TYPE_NAME, CREATE_BY, CREATE_DATE, UPDATE_BY, UPDATE_DATE, REMARKS, DEL_FLAG from T_SMDP_PSP_TAGS WHERE ( DEL_FLAG = ? ) LIMIT ?

Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束
] with root cause

java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令未正确结束

Who knows this question?
锐哥
@itflash
weekendsqls 怎么使用or? builder.orwhere不起作用
@abel533
锐哥
@itflash
没有大佬在吗
锐哥
@itflash
没看到or的用法
daibinNJ
@daibinNJ
domainObjectRenamingRule 这个domainName 不是驼峰的怎么办
@abel533 domainObjectRenamingRule 这个domainName 不是驼峰的怎么办
@abel533 还想问问,表的实例,主键没有自动生成@Id 注解是怎么回事,@Table @Column(name = "id") 这个都是有的
Liuzh
@abel533
@daibinNJ @Id 注解只能看代码找原因,一般建议建个基类配置好主键策略和相关注解,<table> 中配置 rootClass 继承。
大水牛
@it-noob
@abel533 大佬您好,我想请教下,

动态SQL的Example.Criteria是自动创建的

Example example = new Example(Country.class);
Example.Criteria criteria = example.createCriteria();
if(query.getCountryname() != null){
    criteria.andLike("countryname", query.getCountryname() + "%");
}
if(query.getId() != null){
    criteria.andGreaterThan("id", query.getId());
}
List<Country> countries = mapper.selectByExample(example);

不可以用下面这种方式创建的example来动态设置条件吧

Example example = Example.builder(Country.class)
        .select("countryname")
        .where(Sqls.custom().andGreaterThan("id", 100))
        .orderByAsc("countrycode")
        .forUpdate()
        .build();
我看builder模式里的条件和主动创建的条件,不是同一个对象,貌似不生效。
Akhilesh Tyagi
@tyagiakhilesh

Hello, I use mybatis3 with postgres; I am running this query:

Preparing: SELECT * FROM some_table ORDER BY ? ASC LIMIT ? OFFSET ?

but ASC / DESC are not being honored

is this a known bug or something ?
Liuzh
@abel533
@tyagiakhilesh Replace with order by ${orderByColumn} ASC.
Akhilesh Tyagi
@tyagiakhilesh
@abel533 thank you for responding. I did figured that after posting here. But thanks anyway. :-)
Akhilesh Tyagi
@tyagiakhilesh

Hey Guys,
I have stumbled upon something and wanted your advice.
I have a DAO class where I use mybatis3, something like this:

       function1() :
        try (SqlSession session = sqlSessionFactory.openSession(true)) {
            //select
            //update
            session.commit();
        }

      function2():
        try (SqlSession session = sqlSessionFactory.openSession(true)) {
            //update
            session.commit();
        }

      function3():
        try (SqlSession session = sqlSessionFactory.openSession(true)) {
            //insert
            session.commit();
        }

I am facing some deadlocks in postgres with this code under heavy load. Now I wrote some integration tests, and I was able to reproduce the deadlock fairly consistently. I do not really see why the deadlock should happen. I did note though in my code, I am opening session with autocommit true, so I figured I do not need to do an explicit commit. I made that adjustment and removed the session.commit(); lines from each of these functions. And now using the same test case, I am not able to see deadlock problem.

I tried several times and results are pretty consistent: With explicit commit, I do see deadlock issue in postgres. Without explicit commit, I don't see deadlock.

Question: Was/Is deadlock side effect of me doing autocommit session and simultaneously doing an explicit commit ? Can anyone explain this behavior to me?

shannon312
@shannon312
@shannon312
@abel533 这个分页插件代码实现有点欠妥,com.github.pagehelper.PageInterceptor#intercept,这个实现方法里最后并没有调用org.apache.ibatis.plugin.Invocation#proceed这个方法,导致这个插件不能和其他插件共用,也就是不能和其他插件一起组合成InterceptorChain ,这个插件有排他性,使用了你这个分页插件,如果你这个分页插件不是第一个,会导致在你这个分页插件之前的所有插件都不会被调用了
不知道大家有没有发现这个问题
shannon312
@shannon312
soga 了解啦
BALAJI1183
@BALAJI1183
Hi All
Any pointers on bulk insert or bulk update
using MyBatis and using session template
Liuzh
@abel533
@BALAJI1183 batch?
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
BALAJI1183
@BALAJI1183
Hi but I don’t want to manage transaction within this. Is there a way transaction can be handled outside pretty much like JDBCtemplate, hibernatetemplate etc
Seayon
@Seayon
image.png
image.png
image.png