我希望能够从spring属性配置我的数据库表/列名。我通过声明API使用JDBI进行数据访问。我的代码示例目前如下所示:
let
我想使用属性而不是这里定义的常量,类似于import something.model.User;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
public interface UserDAO {
String TABLE_NAME = "user";
String ID = "ud";
String EMAIL = "email";
String PASSWORD = "password";
String FIRST_NAME = "firstName";
String LAST_NAME = "lastName";
String TYPE = "userType";
@SqlQuery("SELECT " + ID + ", " + EMAIL + ", " + PASSWORD + ", " + FIRST_NAME + ", " + LAST_NAME + ", " + TYPE + " " +
"FROM " + TABLE_NAME + " " +
"WHERE " + ID + " = :" + ID
)
User findUserById(@Bind(ID) int id);
}
。但是我无法在网上找到关于这是否可以实现的任何内容。我有预感,这是不可能的,但只是为了确定我决定问,也许有人知道更多。任何建议将不胜感激!