gpt4 book ai didi

java - 使用 SQL 信息填充架构文档和代码注释 使用 Hibernate 工具?

转载 作者:行者123 更新时间:2023-12-01 05:53:52 25 4
gpt4 key购买 nike

我已经在 Eclipse 中设置了 Hibernate Tools,以根据现有数据库自动生成类。对于每个表,我都在 SQL Server 中记录了它们及其每个列。有没有办法使用该文档信息来注释生成的类并填充架构实体文档?我看到可以将元标记放入 hbm.xml 映射文件中,但由于每次我都需要将它们自动生成,所以我需要将它们添加回或不断合并新的更改,而且我理想情况下喜欢让数据库成为“真实”信息,而不是将此类信息存储在映射文件中。有谁知道这是否可能,如果可以的话该怎么做?谢谢...

最佳答案

Is there a way to use that documentation information to comment the generated classes and to populate the schema entity documentation?

据我所知,一些生成的文件中使用了表和列注释,至少在 hibernate-tools.jar 的以下模板中:

  • doc/tables/table.ftl
  • hbm/column.hbm.ftl
  • hbm/persistentclass.hbm.ftl

例如,在hbm/column.hbm.ftl中:

<#if column.isFormula()>
<formula>${column.getFormula()}</formula>
<#else>
<column name="${column.quotedName}" ${c2h.columnAttributes(column)}<#if column.comment?exists && column.comment?trim?length!=0>>
<comment>${column.comment}</comment>
</column><#else>/>
</#if>
</#if>

但是它们没有在带注释的 POJO 的模板中使用,您必须为此修改模板。

关于java - 使用 SQL 信息填充架构文档和代码注释 使用 Hibernate 工具?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3712901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com