Skip to content

[Help]目前自己实现的模型必须要传入PostgreSQLBuilder类似这样的构建类,不同数据库类型的切换的时候,能否这里不传,根据不同的数据库自动对应。 #61

@hawind

Description

@hawind
package com.gdoo.eloquent.model;

import com.gdoo.eloquent.builder.PostgreSQLBuilder;
import com.gdoo.eloquent.datasource.EloquentDataSource;
import gaarason.database.contract.connection.GaarasonDataSource;
import gaarason.database.eloquent.Model;
import gaarason.database.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Collection;

/**
 * 通用model
 * @author xt
 */
@Component
@Slf4j
public class GeneralModel extends Model<PostgreSQLBuilder<GeneralModel.Table, Serializable>, GeneralModel.Table, Serializable> {

    @Override
    public GaarasonDataSource getGaarasonDataSource() {
        return EloquentDataSource.getDataSource();
    }

    public void log(String sql, Collection<?> parameterList) {
        if (log.isDebugEnabled()) {
            log.debug("SQL complete : {}", String.format(StringUtils.replace(sql, " ? ", "\"%s\""), parameterList.toArray()));
        }
    }

    @gaarason.database.annotation.Table(name = "@@GeneralModel_Table@@")
    public static class Table implements Serializable {
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions