如何添加实体栏位?这里演示为PostalAddress添加planet栏位。打开applications/party/entitydef/entitymodel.xml,找到PostalAddress,添加planet栏位:
OFBiz:添加实体栏位-LMLPHP

上面只是修改的实体的定义,但是还没有影响到底层的数据库表结构。重启OFBiz,在console.log中应该有类似下面的内容:

[ DatabaseUtil.java:390:WARN ] Entity [PostalAddress] has 19 fields but table [OFBIZ.POSTAL_ADDRESS] has 18 columns.
[ DatabaseUtil.java:399:WARN ] Field [planet] of entity [PostalAddress] is missing its corresponding column [PLANET]
[ DatabaseUtil.java:1891:INFO ] [addColumn] sql=ALTER TABLE OFBIZ.POSTAL_ADDRESS ADD PLANET VARCHAR(100)
[ DatabaseUtil.java:412:INFO ] Added column [PLANET] to table [OFBIZ.POSTAL_ADDRESS]

这表示数据库表结构已经同步了。

OFBiz启动时为什么会同步数据库表结构?这是因为在framework/entity/config/entityengine.xml有这样的设置:

check-on-start="true"
add-missing-on-start="true"

OFBiz:添加实体栏位-LMLPHP

05-11 11:29