AFAIK JSR-303 is a standard bean validation system.
I don’t know if he could do such checks (I think not):
So, how can I handle checks that depend on the previous state of the object?
I would like to solve such problems in hibernate3.5 - spring3 - JPA2 environment.
thank
My solution was to mess around with hibernate, reload the object to see the old state (after evicting the new object). This time I need a smarter solution ...
I do not think this can be done using JSR 303 validation (or any other validation framework I used). Validation is usually inactive - you pass it an instance of the object, and your validation environment checks things to make sure that the current values of your object are valid. There is no real knowledge of the previous states of the object.
You can do this - simply not with validation. You can use the property of a restricted property , or you can do this work using a proxy template or AOP.
, , ( ), , . (idDeleted, createdDate ..) . , , , , , .
, , , , , , . . Hibernate , , INSERT UPDATE .
, .
, ?
100%, , , - , " " " " (), . , , , .
, , , , , . , , . .
, makeACopy(), .
, Clonable , , . makeACopy() , .
. , JSR-303 , "".
...
. ...
,
, . - "deleted". true, , .
. , ( ) .
bean
, , - ( ).
, AOP - , . .
, , JPA. Spring AOP , Spring .
, . , .
:
public void setCounter(int newCounter) { if (newCounter < this.counter) { throw new IllegalOperationException("Cannot decrease the counter"); } else { this.counter = newCounter; } }
Instead, you can watch OVal . We check all this time. This is usually done using SimpleCheck, where you get the object and value and can do all kinds of cross-validation.
Source: https://habr.com/ru/post/1746143/More articles:Getting key / value pairs from xml plist style using simplexml in php - phpCan I call / request .net handler (ashx) using javascript? - javascriptProblems reading registry with Delphi 7 on Windows 7 64 bit - windowsCall Pinvoke to get a Windows serial number? - .netвыполнить процедуру для последовательности элементов (выполнить theProc (выбрать id из таблицы)) - sqlMaking report. Requires a set of MS Word templates - .netАтомная переменная Vs. Атомная операция - multithreadingproblem with reading arabic language on jsp page? - jspКак получить доступ к галерее → Видеоролики камеры и отобразить их в списке на кнопке Нажмите? - androidC # program to indicate whether open applications are in maximization mode or not - c #All Articles