次のように定義されたドメインクラス User があります
class User extends SecUser{
String fullName
String address
String city
String country
String role
String email
String schoolName
String gradeLevel
static constraints = {
fullName(nullable:true)
username(blank:false, unique:true)
password(size:6..20, blank:false)
//passwordRepeat(validator:)
email(email:true, nullable:true, unique:true)
address(nullable:true)
city(nullable:true)
country(nullable:true)
phone(nullable:true) //10 digit phone number, no spaces
role(blank:false, inList:['Teacher', 'Donor', 'Both'])
schoolName(nullable:true)
gradeLevel(nullable:true, inList:['K', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', 'College'])
}
}
SecUser は、Spring Security Grails プラグインのクイックスタート スクリプトを実行することで実装されるクラスです。そのように定義されています
class SecUser {
transient springSecurityService
String username
String password
boolean enabled
boolean accountExpired
boolean accountLocked
boolean passwordExpired
static constraints = {
username blank: false, unique: true
password blank: false
}
}
通常、結果として得られるデータベース テーブルは、上記のフィールドを列として持つ USER テーブルであり、UserController メソッドを使用して CRUD を実装できると考えていました。問題は、User テーブルが作成されず、上記のフィールドを使用して SEC_USER テーブルがインスタンス化されることです。
私の問題は、新しいユーザーの作成と関連フィールドへの入力に関係しています。USER テーブルが存在しないため、User ドメイン オブジェクトからレコードを挿入できません。
一方、SEC_USER テーブルにレコードを挿入することはできますが、フィールドは SecUser ドメイン クラスで定義されたものに限定されます。新しい SecUser インスタンスを介して User の特定の列に項目を挿入しようとすると、プロパティが定義されていないというエラー メッセージが表示されます。
ユーザー登録プロセスを完了するには、関連するフィールドにアクセスし、挿入し、更新する必要があるため、これはややイライラしますが、アクセスせずにそれを行うにはどうすればよいですか?