How to implement database operations logging in Hibernate + Spring - spring

I'd like to be able to log somewhere (maybe a table) every inserte/update/delete in the db. I'm using spring + hibernate. I'm open to a solution based on either or both.
Any ideas?
Edit
I didn't mean textual logging, but actually to intercept the operations or have them logged in some data structure that can be processed.

If logging to a properties file is OK to you just add in your log4j.xml config:
<category name="org.hibernate.SQL" additivity="false">
<priority value="trace"/>
<appender-ref ref='file'/>
</category>
With log4j.properties:
log4j.category.org.hibernate.SQL=TRACE, file
where "file" is an appender defined like this:
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=SOME_PATH/sql_log.log
log4j.appender.file.Append=true
log4j.appender.file.encoding=UTF-8
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%-9t] %-5p %c{1}.%m%n

If you don't need the actual SQL sentences, you can use an aspect over you DAOs. This way you can intercept every data access operation and insert a register in a DATA_ACCESS_LOG table describing the operation and the parameters passed.

Related

React-admin - how should be the exposed data from the backend - hasura/graphql

i'm using ReactAdmin(3.19.6) with ra-data-hasura(0.2.0) dataprovider
it works for tables but don't for Actions
when the ReactAdmin start a message appears
Unknown resource apikeyReceived. Make sure it has been declared on your server side schema. Known resources are comunicazioni, comunicazioni_aggregate, ping, ping_aggregate, profiles, profiles_aggregate
apikeyReceived is an action resource and probably it isn't in the aspected shape from ReactAdmin (it miss some property or metadata that reactadmin needs)
<Admin dataProvider={dataProvider} >
<Resource name="comunicazioni" list={ListGuesser} />
<Resource name="apikeyReceived" list={ListGuesser} />
</Admin>
i think this message is popped out when react admin execute the introspection query.
Is there a way i can intercepr this "event" and override or add something?

KendoPivot and Mondrian XML/A server

I would like to know if anyone has implemented KendoPivot accessing an instance of Mondrian as XML/A server. In theory this should work but I'm wondering if there are any compatibility issues.
I tested KendoPivot and Mondrian, and it works well. What you need to take into account is that you have to name your hierarchies, if you don't it'll take the default name (the dimension name). For example you need to include name="theStore":
<Dimension name="Store">
<Hierarchy hasAll="true" primaryKey="store_id" name="theStore">
<Table name="store"/>
<Level name="Store Country" column="store_country" uniqueMembers="true"/>
<Level name="Store State" column="store_state" uniqueMembers="true"/>
.....
.....

Updating data in a XML file in marklogic using java api

Say I inserted XML file in MarkLogic datastore:
<Providers>
<Provider>
<UniqueId>1111</UniqueId>
<name>John Doe</name>
<Age>40</Age>
<Country>MN</Country>
</Provider>
<Provider>
<UniqueId>2222</UniqueId>
<name>Johny Deep</name>
<Age>51</Age>
<Country>NY</Country>
</Provider>
</Providers>
Now if I want to update the name to 'Jane Doe' where Unique Id is '1111', how can I achieve this using MarkLogic's java API?
Goel, it sounds like you need the Patch operation. This allows you to specify a specific part of a document and add to, change, or delete it.

Camel / AggregationStrategy after tokenizeXML

I want to know the number of order saved after split().tokenizeXML
i have a xml
<orders>
<order>
....
my route
.split().tokenizeXML("order")
.unmarshal("xmlbsondataformat")
.beanRef("orderShopConnector", "saveOrder")
in my bean orderShopConnector, i add in header properties saveOK=1.
headers.put("ordersave",1);
now, I want know the sum of the order saved, in the firstexchange properties.
I think use AggregationStrategy but i canot see how to use after tokenizeXML, it is possible?
See the examples at the Camel docs, and you can see how to use a tokenizer and aggregation strategy together: http://camel.apache.org/splitter, for example at the Split aggregate request/reply sample example.

How to sort data from DropDownList component?

I'm developing a simple Web App which has a simple data from some employees, such as ID, NAME and so on. Thus, I'm using a XML file as my database. Yet, my XML file is sorted by the Employees' ID.
However, I'm using a to select the Employee's Name and show some informations about him/her, but when I created the bindable data through my spark component (I just "drag-and-drop" my XML file into the component), I'd like to show those names sorted by Name and this is my problem.
It's suppose to be a simple code, but I'm in trouble with it... lol!
<s:DropDownList id="ddNome"
labelField="NomeFuncionario" <!-- Employees' Name -->
textAlign="justify"
width="240" height="25"
top="30" horizontalCenter="0"
initialize="sortName(event)" <!-- Trying to create it now... -->
creationComplete="cbNome_creationCompleteHandler(event)"
change="cbNome_changeHandler(event)">
<s:AsyncListView list="{getDataResult2.lastResult}"/>
</s:DropDownList>
I'd be really grateful for any help with this code.
you can try something like this
<mx:XMLListCollection id="xmlListColl"
source="{getDataResult2.lastResult}">
<mx:sort>
<mx:Sort>
<mx:fields>
<mx:SortField id="sortField"
name="#NomeFuncionario"
caseInsensitive="true" />
</mx:fields>
</mx:Sort>
</mx:sort>
</mx:XMLListCollection>
...
<s:AsyncListView list="{xmlListColl}"/>
...

Resources