[英]Can I call a Java static function from liquibase xml?
I have an existing project which is on production.我有一个正在生产的现有项目。 I am looking to update a column's value.
我正在寻找更新列的值。 And the business methods are ready.
业务方法已准备就绪。 Can i call this function via liquibase xml?
我可以通过 liquibase xml 调用这个 function 吗? I would also need to pass an existing value from the table into the method.
我还需要将表中的现有值传递给方法。
<changeSet id="update_badges_hashes" author="Rakhunathan">
<update tableName="badges">
<column name="hashtags" valueComputed="${net.compant.app.util.Generator.getData('1')}" />
</update>
</changeSet>
This implementation throws error and I am looking for the correct way to do it.此实现会引发错误,我正在寻找正确的方法。
Perhaps I'm missing something but as far as I know, if you need to execute some Java method then the only thing you can do is to create your custom changeSet.也许我遗漏了一些东西,但据我所知,如果您需要执行一些 Java 方法,那么您唯一能做的就是创建自定义更改集。
You can use the customChange
:您可以使用
customChange
:
<changeSet id="foo" author="bar">
<customChange class="your.package.liquibase.YourJavaChangeSet"/>
</changeSet>
And Java class could look like this: Java class 可能如下所示:
public class YourJavaChangeSet implements CustomTaskChange {
@Override
public void execute(Database database) throws CustomChangeException {
// your logic here
}
@Override
public String getConfirmationMessage() {
return null;
}
@Override
public void setUp() throws SetupException {
}
@Override
public void setFileOpener(ResourceAccessor resourceAccessor) {
}
@Override
public ValidationErrors validate(Database database) {
return null;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.