views:

229

answers:

1

I have a endpoint mapping a webservice which is used to insert in the dabatabase some keywords:

@Transactional(readOnly = false,isolation= Isolation.SERIALIZABLE)
public Source saveKW(...).

The input is a request.

I would like to add an interceptor on the method in order to validate the parameters. this one will read some values from the DB.

i would like that this interceptor is EMBED in the transaction declared for the endpoint (or this opposite). In other words, i want them to be in the same transaction.

Ideally im looking for something like this with annotation:

@Transactional(readOnly = false,isolation= Isolation.SERIALIZABLE)
@validator("KeyWordValidaor.class")
public Source saveKW(...)

where KeyWordValidaor will be class validating the parameters.

Have you any idea or short examples to implements this like this way or in a other real way?

A: 

Hi, The validation has to be inside the transaction because it is querying the database to test constraints for example. I have already found my solution. Im using spring aop & i load dynamically the appropriate validator from the spring context throuh a map. (very & unknown feature of autorwired unknow beans name in advance!). Thanks to the order attribute ,it is inside the transaction.

mada54