GrailsアプリからPostgreSQLデータベースのレガシー テーブルに接続しようとして数日間成功しませんでした。
私が欲しいもの
ログイン資格情報を確認するために、grails アプリからこのテーブル (ユーザーが保存されている) にクエリを実行するだけです。ユーザーが grails アプリにログインし、提供されたパスワードがこのテーブルに保存されているものと一致することを確認する必要があります。
私がアクセスしようとしているテーブルは " user " (キーワード) と呼ばれているので、考えられる問題を回避するために、grails から使用している別名ビュー " users " を作成しました。
以下に、誰かが私を助けてくれることを願って、私の問題に関する追加情報を提供しています。
手動クエリの結果
select * from public.users
コンソールで postgres から直接実行すると、次の結果が得られます。
id | name | apikey | created | about | openid | password | fullname | email | reset_key
--------------------------------------+-----------+---------------------------+----------------------------+-------+--------+-------------------------------+----------+------------------------------+-----------
ef8661be-6627-40e3-8b58-e78f3363680f | logged_in | this-is-an-api-key-sample | 2012-12-11 14:17:28.949515 | | | | | |
0c49f23a-350c-43d9-a1ec-34057125acd7 | visitor | this-is-an-api-key-sample | 2012-12-11 14:17:28.953194 | | | | | |
591798d4-f85e-4bc2-a352-a41635c83653 | admin | this-is-an-api-key-sample | 2013-04-10 15:08:47.104103 | | | thisisanencodedpasswordsample | admin | username@email.com |
25c8b15f-ec67-472b-b551-3c7112d4a2db | grails | this-is-an-api-key-sample | 2013-04-10 15:12:44.257821 | | | thisisanencodedpasswordsample | grails | username@email.com |
私のgrailsアプリから、次のファイルがあります:
ユーザー ドメイン クラス
class User {
String user_id
String name
String apikey
String created
String about
String openid
String password
String fullname
String email
String resetKey
static mapping = {
version false
autoTimestamp false
table "public.users"
resetKey column: "reset_key"
created column: "created", sqlType: "timestamp without time zone"
user_id column: "id", sqlType: "text"
id name: 'user_id'
}
}
情報源
dataSource {
pooled = true
dbCreate = "validate"
logSql = true
url: "jdbc:postgresql://192.168.1.100:5432/ecodata"
driverClassName = "org.postgresql.Driver"
dialect = net.sf.hibernate.dialect.PostgreSQLDialect
username = "ecodata"
password = "******"
}
POM の依存関係
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>hibernate</artifactId>
<version>2.1.2</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
<scope>runtime</scope>
</dependency>
grails アプリの起動時に発生するエラーは次のとおりです。
[...] 原因: org.hibernate.HibernateException: Missing table: users [...]
誰かがこれを手伝ってくれることを願っています。前もって感謝します。
よろしく