私はgrailsでドメインクラスを持っています...どのようにして、dbを作成するときにこのエンティティを削除するようにしますか?ちょうどそれを残す。Grails Entity without persist
答えて
あなたはドメインクラスである必要はありません。 src/groovyファイルにPOGOを作成するだけです。私の前提が間違っている場合は、あなたが達成しようとしていることをさらに説明してください。
コマンドオブジェクトを使用できます。
http://grails.org/doc/latest/guide/single.html#commandObjects
彼らはデータバインディングとドメインクラスの検証を提供しますが、データベースにマップされません。
私が理解すれば、ドメインクラスからテーブルを作成したくないのですか?はいの場合は、ドメインクラス内で次のコードを使用してください。
static mapWith = "none" // disable persisting into database
この質問に対するその他の回答はうまく役立ちますが、これは厳密には質問に対する正解です。 – scrotty
'mapWith'のデフォルト値は' 'GORM" 'です。 [grailsソース](https://github.com/grails/grails-core/blob/31af2108f171534edca3f6f15391364ee1fb2641/grails-core/src/main/groovy/org/grails/core/DefaultGrailsDomainClass.java)を参照してください。 – GreenGiant
- 1. Grails security without spring
- 2. Doctrine without Entityでテーブルを結合する
- 3. symfony2 persist manyToOne
- 4. FontAwesome without without www
- 5. JPA - OneToMany persist - EntityExistsException
- 6. HibernateカスケードPERSIST
- 7. Persist FileUploadコントロール値
- 8. Persist @ManyToOne NULL
- 9. Reactjs、Redux - redux-persist
- 10. Persist Facebookアクセストークン
- 11. JPA persist genericエンティティ
- 12. Spring JDBC Persist ZonedDateTime
- 13. RouteLinkのPersist QueryStringパラメータ
- 14. Persist UITableViewCellサブクラスのプロパティ
- 15. react-native fetch()cookie persist
- 16. Firebase Auth C++ - persistログイン
- 17. OAuth&Access Token Persist Question
- 18. Doctrine2 strange persist例外
- 19. マクロエラー - For without For
- 20. QApplication without display
- 21. numpy unique without sort
- 22. rebar dependency without repository
- 23. symfony urls without app.php
- 24. isomorphic react.js without flux
- 25. Git Branches without Pulling
- 26. TabControl ItemTemplate without ItemsSource
- 27. Ember Ember Without Ember?
- 28. JavaFx FileChooser without stage
- 29. npm install without ssl
- 30. C#SuperSocket without protocol
コマンドオブジェクトが検証可能になるという副作用を利用しています。 src/groovyクラスを作成し、 'grails.validation.Validateable'を使って注釈を付ける方が良いでしょう –
コマンドオブジェクトのGrailsドキュメントは、検証機能に特に注意するので、副作用として扱われているようには見えません。 – Patrick
コマンドオブジェクトをコントローラに宣言して、コマンドオブジェクトにする必要があります。コマンドオブジェクトとして使用せずに、非永続ドメインクラスとしての検証機能を利用するだけでは、それは副作用です。 –