「プロジェクトに接続が指定されていません。データベース固有の検証は実行されません。」という警告が出る場合の対処方法。
日本語で検索してもほとんどヒットしないので、対応する英語のメッセージを検索してみると、
「No connection specified for the project. No data-specific validation will be performed」が見つかる。
このメッセージで検索すると、以下のページが見つかる。
http://ask.programmershare.com/676_21118951/
No connection specified for project. No database-specific validation will be performed Eclipse Marker is related to JPA.
You can perform following things to eliminate markers:-
1.You can either add the required datatools
2.disable the JPA validator right-click on the project in which marker error is showing select Properties—>>>Validation).
検証を実行させたい場合はデータツールを追加する。
- プロジェクトのプロパティを開き、左側のリストで「JPA」を展開。
- 「エラー/警告」を選択。
- 「プロジェクト固有の設定を可能にする」をチェック。
- 「プロジェクト」を展開。
- 「指定された接続がないプロジェクト」の右側のドロップダウンを「無視」にする。
Criteria APIでテーブルの行をランダムに取り出す方法
Criteria APIのorderByでは昇順か降順しか指定できない。
ランダムに取り出すには、以下のコードで制約を記述する。
criteria.add(Restrictions.sqlRestriction("1=1 order by rand()"));