Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Access logging in database
Access logging in database [message #1202659] Fri, 22 November 2013 08:52 Go to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
Hi,

I have a requirement that it must be clear who read and/or changed some particular data.

For this I want to log every read / insert and update to particular data. I think of adding some generic logging that logs to a database. At least I must log the dateTime, the user, the object involved and the changed data.

I don't have to log all access only those that involve some medical data.

What would be the best way to do this in Scout.

Regards Bertin
Re: Access logging in database [message #1208824 is a reply to message #1202659] Mon, 25 November 2013 07:40 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Are you using Scout's SQL service that let you use SQL statement strings to access your DB?

In our project, we are using a combination of spring/hibernate for persistence which allows us to define interceptors on DB access. Those interceptors then update some fields that are common to all our tables (time, user, etc). This has the advantage that we do not need to add this to any of our business code, all we need to do is to add those fields to the database tables and let our hibernate bean implement a marker interface the interceptor checks for.

I don't know if the SQL services that come with Scout offer a similar possibility.
Re: Access logging in database [message #1209095 is a reply to message #1208824] Mon, 25 November 2013 10:32 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
I only use Scout SQL service (extends AbstractSqlService).

I think I have read something about implementing logging in the tunnelService or servlet filter but can't find it anymore.

Regards Bertin

Re: Access logging in database [message #1209601 is a reply to message #1209095] Mon, 25 November 2013 16:00 Go to previous message
Florian Widmer is currently offline Florian WidmerFriend
Messages: 8
Registered: March 2012
Junior Member
Our project has a similar requirement. The difference is, that updates through other clients such as SQLDeveloper have to be recorded as well. In this case it is impossible to implement a solution in Scout alone. Also, we don't have to record a SELECT.

The database supports triggers. We're using the triggers to record the update / insert / delete of data. Since the database does not know which user is issuing the updates through the Scout server, we also use a transaction specific variable to store the username and record it with every trigger execution.

In the SQLService:
@Override
  protected void execBeginTransaction() throws ProcessingException {
    SQL.callStoredProcedure("CALL trg_audit_pack.set_scout_session(:user)", new NVPair("user", ServerSession.get().getUserId()));
  }

  @Override
  protected void execEndTransaction(boolean willBeCommitted) throws ProcessingException {
    SQL.callStoredProcedure("CALL trg_audit_pack.clear_scout_session()");
  }


Logging at the servicetunnel sounds like a great idea at first, but it runs into trouble when a service calls another service on the backend; those calls don't go through the servicetunnel.

If your requirements are not that strict and you would just like to log every time a specific type of data is sent through the tunnel you might find the DefaultTransactionDelegate useful.
Previous Topic:SWT Client startup Error
Next Topic:How to create a read only field
Goto Forum:
  


Current Time: Tue Mar 19 05:29:17 GMT 2024

Powered by FUDForum. Page generated in 0.01725 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top