I have three Tables A
, B
, and AB
. AB table is a relationship table. So AB_AUD
table has abID
as PK, and aId
, bID
, Revision Info.
I've got list of 'bIds' and would like to retrieve audit data from AB_AUD
table using the list. My code block is
AuditQuery query = auditReader.createQuery()
.forRevisionsOfEntity(AB.class, false, true)
.add(AuditEntity.property("bId").in(bIds))
.addOrder(AuditEntity.revisionNumber().desc());
This throws exception :could not resolve property of bId. Even I tried equating with single bId
to retrieve audit data for a single bId
which threw same exception
.
I would like to know if there is any mistake in the code. For now I am doing a for loop to retrieve data like this:
for (B b : listofB's)
{
AuditQuery query = auditReader.createQuery()
.forRevisionsOfEntity(AB.class, false, true)
.add(AuditEntity.property("b").eq(b))
.addOrder(AuditEntity.revisionNumber().desc());
}
Which runs sql query
for every B, which isn't a good way.