|
|
|
|
Re: get Information about locked database items [message #908938 is a reply to message #908126] |
Thu, 06 September 2012 05:08   |
Eclipse User |
|
|
|
Thanks for your hints. Yesterday I got the connection working.
Unfortunatelly I haven't found an easy way to obtain the data from the database. I don't know if it's because of my very basic understanding of JPQL or the task is just not that easy.
Seems like I would have to write dedicated code for every possible type of PO that is lockable.
Here is what i've got so far. If the lock locks a DataSet, it gives you the name of the Project the DataSet is from.
List<DbLockPO> locks = null;
List<ITestDataCategoryPO> cats = null;
List<INodePO> nodes = null;
try {
locks = em.createQuery("select lock from DbLockPO as lock").getResultList();
for (DbLockPO dbLockPo : locks) {
System.out.println("got item: "+dbLockPo.getPoId());
Query queryCats = em.createQuery("select cat from TestDataCategoryPO cat where cat.id = :catId", ITestDataCategoryPO.class);
queryCats.setParameter("catId", dbLockPo.getPoId());
cats= queryCats.getResultList();
for (ITestDataCategoryPO catPO : cats) {
Query queryNodes = em.createQuery("select node from NodePO node where node.id = :nodeId", INodePO.class);
queryNodes.setParameter("nodeId", catPO.getParentProjectId());
nodes = queryNodes.getResultList();
for (INodePO iNodePO : nodes) {
System.out.println("Locked Dataset belong to: "+iNodePO.getName());
}
}
}
}
catch(Exception e){
e.printStackTrace();
}
I know, that not all the loops are neccessary, but it helps to find issues when a ResultSet is supposed to have only one entry but has more.
I you have an easier solution to do this, please tell me. Would be helpful to have an example JPQL query with JOINS to see how it is done in Jubula context.
When I have this working I would really like to contribute the plugin to the community.
I really appreciate your help, thanks for your help so far.
Peter
[Updated on: Thu, 06 September 2012 05:10] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06114 seconds