gpt4 book ai didi

grails - GORM 数据服务 VS Grails 服务

转载 作者:行者123 更新时间:2023-12-01 01:46:51 24 4
gpt4 key购买 nike

GORM 6.1 引入了数据服务的概念。我认为它们是在编译时检查的自动生成的持久性逻辑。我对以下内容有些困惑:

  • 它们与 Grails 服务有何不同(除了编译时间差异)?
  • 是否仍然可以在 GORM 数据服务中实现我的自定义业务逻辑,或者我是否需要维护两个服务,一个用于持久性 (GORM),另一个 (GRAILS) 用于其他与持久性无关的业务逻辑(例如发出外部 REST 请求并根据响应采取行动)。
  • 我注意到 grails generate-all Domain为 REST 配置文件生成数据服务接口(interface)。这让我对我们是否可以在服务中使用非持久性相关的方法名称感到困惑。

  • 更新:我要问的是: gorm.grails.org/latest/hibernate/manual/#dataServices .我试图了解这些与此有何不同: docs.grails.org/latest/guide/services.html以及何时使用它们。

    最佳答案

    How are they different from Grails Services (aside from the compile time difference)?



    GORM 数据服务是 Grails 服务。

    Is it possible to still implement my custom business logic inside the GORM Data Services or do I need to maintain two services, one for persistence (GORM) and the other (GRAILS) for other none persistence related business logic (e.g making an external REST request and acting on the response).



    您可以将业务逻辑放在您喜欢的任何服务中。一般来说,GORM 数据服务中的逻辑应该与数据库交互相关,但这完全取决于您。如果您愿意,可以将 100% 的业务逻辑放在 GORM 数据服务实例中,尽​​管这没有意义。 GORM 数据服务是一项服务,您可以在其中放入任何您喜欢的内容。

    I noticed grails generate-all Domain generates a Data Service interface for REST profile. This leaves me confused as to whether we can have non persistence related method names in the service.



    您可以在服务中使用非持久性相关的方法名称。您可以在服务中添加任何您想要的内容。

    我将采取的方法是,我将 GORM 数据服务用于与数据库相关的代码,并将传统的 Grails 服务用于其他所有内容,并在适当的情况下将 1 注入(inject)另一个。

    关于grails - GORM 数据服务 VS Grails 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48017732/

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