
org.eweb4j.orm.dao.DAOUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eweb4j-all Show documentation
Show all versions of eweb4j-all Show documentation
easy web framework for java, full-stack
The newest version!
package org.eweb4j.orm.dao;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.eweb4j.orm.config.ORMConfigBeanUtil;
import org.eweb4j.orm.jdbc.JdbcUtil;
import org.eweb4j.orm.sql.OrderColumnUtil;
@Deprecated
@SuppressWarnings("all")
public class DAOUtil {
public static Number selectMaxId(T t, Connection con, String dbType)
throws SQLException {
String idColumn;
String table;
Class> clazz;
if (t instanceof Class) {
clazz = (Class>) t;
} else {
clazz = t.getClass();
}
if (!(t instanceof Class) && Map.class.isAssignableFrom(clazz)) {
HashMap map = (HashMap) t;
idColumn = (String) map.get("idColumn");
table = (String) map.get("table");
} else {
idColumn = ORMConfigBeanUtil.getIdColumn(clazz);
table = ORMConfigBeanUtil.getTable(clazz, true);
}
if (idColumn == null)
return 0;
idColumn = OrderColumnUtil.getOrderColumn(idColumn, dbType);
String format = "select max(%s) from %s ";
String sql = String.format(format, idColumn, table);
Number id = JdbcUtil.getInteger(con, sql);// 获得最新插入的ID值
return id;
}
public static void main(String[] args) {
System.out.println(Class.class.getClass());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy