如何在不使用 JOOQ 重新部署的情况下删除 mysql 列
How to drop a mysql column without redeploying with JOOQ
我想从数据库中删除一列而不同时重新部署应用程序。
我正在为 table 使用 JOOQ 生成的文件,并且我已经从代码中删除了该字段的所有使用,因此没有该字段的 'get' 或 'set',但是当记录被提取,该字段仍在查询中。因此,如果我删除该列,代码将会中断。
我正在考虑编辑 JOOQ 生成的文件,但不确定这是否有效,因为字段似乎在其中编号(可能基于它们在 table 中的索引)。
/**
* Setter for <code>database.person.email</code>.
*/
public void setEmail(String value) {
set(7, value);
}
/**
* Getter for <code>database.person.email</code>.
*/
public String getEmail() {
return (String) get(7);
}
您似乎在使用 selectFrom(Table)
. It will always produce an explicit column list from Table.fields()
in the SELECT
clause, if the column list is known to jOOQ. This should probably be better documented。
此行为(与生成 SELECT *
相对)的结果是:
- 您可以在 table 中添加一列而无需重新生成 jOOQ 代码
- 您不能只从 table 中删除列而不重新生成 jOOQ 代码
然而,理想情况下,您应该始终在投影中使用明确的列列表,而不是投影所有列,除非您无论如何都需要其中的大部分。这不仅可以防止这种问题在大多数情况下发生,还可以通过多种方式提高性能。
I am thinking about editing the JOOQ generated files, but unsure if this will even work as the fields seems to be numbered in there (maybe based on their index in the table).
如果编辑这些文件是一种选择,那么重新生成和重新部署也可能是一种选择。我建议不要手动编辑这些文件。如果必须,请确保编辑生成的 Table
和 TableRecord
类,并调整 所有 列索引。
我想从数据库中删除一列而不同时重新部署应用程序。
我正在为 table 使用 JOOQ 生成的文件,并且我已经从代码中删除了该字段的所有使用,因此没有该字段的 'get' 或 'set',但是当记录被提取,该字段仍在查询中。因此,如果我删除该列,代码将会中断。
我正在考虑编辑 JOOQ 生成的文件,但不确定这是否有效,因为字段似乎在其中编号(可能基于它们在 table 中的索引)。
/**
* Setter for <code>database.person.email</code>.
*/
public void setEmail(String value) {
set(7, value);
}
/**
* Getter for <code>database.person.email</code>.
*/
public String getEmail() {
return (String) get(7);
}
您似乎在使用 selectFrom(Table)
. It will always produce an explicit column list from Table.fields()
in the SELECT
clause, if the column list is known to jOOQ. This should probably be better documented。
此行为(与生成 SELECT *
相对)的结果是:
- 您可以在 table 中添加一列而无需重新生成 jOOQ 代码
- 您不能只从 table 中删除列而不重新生成 jOOQ 代码
然而,理想情况下,您应该始终在投影中使用明确的列列表,而不是投影所有列,除非您无论如何都需要其中的大部分。这不仅可以防止这种问题在大多数情况下发生,还可以通过多种方式提高性能。
I am thinking about editing the JOOQ generated files, but unsure if this will even work as the fields seems to be numbered in there (maybe based on their index in the table).
如果编辑这些文件是一种选择,那么重新生成和重新部署也可能是一种选择。我建议不要手动编辑这些文件。如果必须,请确保编辑生成的 Table
和 TableRecord
类,并调整 所有 列索引。