在休眠状态中,我可以使用以下代码来对实体进行所有更改:
document.Save(xmlLocation);
但是有没有办法获得特定用户对所有实体所做的所有更改?
我使用以下实体存储修订信息:
void __cdecl _tmain(int argc, TCHAR *argv[])
{
DWORD dwFilter = REG_NOTIFY_CHANGE_NAME |
REG_NOTIFY_CHANGE_ATTRIBUTES |
REG_NOTIFY_CHANGE_LAST_SET |
REG_NOTIFY_CHANGE_SECURITY| REG_NOTIFY_THREAD_AGNOSTIC;
HANDLE hEvent;
HKEY hMainKey;
HKEY hKey;
LONG lErrorCode;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\444\\1"), 0, KEY_NOTIFY | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hKey);
// Create an event.
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent == NULL)
{
_tprintf(TEXT("Error in CreateEvent (%d).\n"), GetLastError());
return;
}
// Watch the registry key for a change of value.
lErrorCode = RegNotifyChangeKeyValue(hKey,
TRUE,
dwFilter,
hEvent,
TRUE);
if (lErrorCode != ERROR_SUCCESS)
{
_tprintf(TEXT("Error in RegNotifyChangeKeyValue (%d).\n"), lErrorCode);
return;
}
// Wait for an event to occur.
_tprintf(TEXT("Waiting for a change in the specified key...\n"));
if (WaitForSingleObject(hEvent, INFINITE) == WAIT_FAILED)
{
_tprintf(TEXT("Error in WaitForSingleObject (%d).\n"), GetLastError());
return;
}
else
{
//Get chile events for the event key ... In this case select. Display the key name and values.
_tprintf(TEXT("\nChange has occurred.\n"));
std::cout << hEvent << std::endl;
_tprintf(TEXT("the modified key is",hEvent));//this was commited
Sleep(2000);
return;
}
// Close the key.
lErrorCode = RegCloseKey(hKey);
if (lErrorCode != ERROR_SUCCESS)
{
_tprintf(TEXT("Error in RegCloseKey (%d).\n"), GetLastError());
return;
}
// Close the handle.
if (!CloseHandle(hEvent))
{
_tprintf(TEXT("Error in CloseHandle.\n"));
return;
}
system("pause");
}
此模型的条目将在每次更改时使用以下侦听器添加:
AuditQuery aq = auditReader.createQuery().forRevisionsOfEntityWithChanges(DummyEntity.class, false);
答案 0 :(得分:1)
您正在寻找AuditEntity#revisionProperty
方法:
List results = auditReader.createQuery()
.forRevisionsOfEntityWithChanges( DummyEntity.class, false )
.add( AuditEntity.revisionProperty( "userId" ).eq( userId ) )
.getResultList();
添加了#revisionProperty
方法,以允许在其审核域模型中扩展或使用自定义修订实体实例的用户能够添加限制/预测或能够基于该模型上的字段对结果进行排序