新しいサービスを開発しています。回避策としてSQLが提供されています。しかし、これはかなり難しい問題であることが証明されています。
"@formula"を使用して、デコード機能をhibernate.cfg.xmlに追加しようとしました。そして、私はその問題を回避することを見たことがありません。デコードとユニオンの問題が発生せずにコードを実行しようとしました。
コントローラ
public ResponseEntity<List<Object>> listAll() {
logger.info("ListAllApplications");
List<Object> allApp = null;
try {
allApp = Service.listAll();
logger.info("return ListAll");
if (allApp == null) {
return ResponseEntity.status(400).body(null);
}
return ResponseEntity.ok().body(allApp);
} catch (Exception e) {
return ResponseEntity.status(500).body(allApp);
}
}
論理
public List<Object> listAll() {
Session session = sessionFactory.getCurrentSession();
logger.info("Request AllApplications :session");
String hql = ""
Query query = session.createQuery(hql);
logger.info("Request Join: :query");
List<Object> results = query.list();
return results;
}
上記の文字列HQLでのクエリ
'String 3', 'String 4', t.initial_state) m), t.bmp from com.model.Table1 T
where t.initial_state = 'F' and exists (select 'X' from com.model.Table2 b where t.table_info = b.table_info
and t.table_app = b.table_app and t.version = b.version and b.block != 'S')";
UNION
select a.table_info, a.table_app, a.version, desc, initial_state, bmp from com.model.Table1 a,
com.model.Table3 b, com.model.Table2 c where a.table_info
IN ('LDAP') and a.table_info = b.table_info and a.table_app = b.table_app
and a.version = b.version and a.table_info = c.table_info and a.table_app = c.table_app
and a.version = c.version and c.block != 'S' order by 1,4
与えられたとおりに選択できるようにしたいと思います。しかし、同様のソリューションであれば問題ありません。
敬具。
私は言及の問題を回避することができませんでした。そこで、ビューでクエリを作成し、DBビューで試しました。問題を完全に解決しました。私のコードで疑似モデルを作成し、単純なクエリに変更しました。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加