Special entity validation

Hello all,
I have a special case and need help to find the best solution. I have a Boolean field (attribute) in an entity and I want to create an entity or attribute validation that only for one record in the entire table that field is TRUE.
I appreciate any help.
Sayyed

Sayeed,
If you want to do this correctly (i.e. have it work even when there are multiple users), you MUST do one of the following:
* Do your validation in the database (more below)
* Lock the entire table and ensure that all inserts/updates/deletes are serialised
The simplest and most straightforward way to do this in the database (assuming Oracle DB) - is this:
create unique index foo on your_table(decode(the_column, 'FALSE', null))
In this way, the database will handle all of the concurrency issues for you, and because NULL values are not stored in a normal index in Oracle (and thus do not count for uniqueness) - the index will do what you need.
There are many ways of doing this incorrectly, so tread carefully if you decide to build something on your own.
John

Similar Messages

  • How to stop attribute level validation when entity validator fails?

    Hi,
    Can you suggest any way to achieve the desired behaviour on the following scenario.
    Table contains the following columns
    1. Grade
    2. Grade Rate
    3. Status
    Constraints:
    1. Grade and Grade Rate together must be unique.
    2. Grade and Grade Rate are mandatory fields.
    Implementation:
    1. Have Mandatory validator at attribute level for Grade and Grade Rate by default.
    2. Alternate key is defined based on Grade and Grade Rate and added the same as Entity validator.
    User operation scenario:
    User adds a row in a table, entered 'GradeOne' as Grade, tabbed out and then entered '5 %' as Grade Rate (Existing row of the VO has a row with similar data already). When user try to navigate to other row, both validation at attribute level and entity level fires and gives the following error messages.
    Error Msg 1. Grade and GradeRate should be unique.
    Error Msg 2. Attribute GradeRate is required.
    Expected behaviour:
    I can understand the reason why ADF throws both the errors (coz it didn't consider the invalid value of GradeRate posted into attribute), but the error messages confuses the user. It would be great if he get only one error message in this scenario (i.e. Unique validation alone)
    Question:
    How can I restrict in such a way that only one error validation happens in a request (i.e. either attribute level or entity level or in a particular order}
    Thanks in Advance.

    Hi,
    the reason ADF does this is for performance. What if you create a custom error handler in the DataBindings.cpx file and use this to suppress all other errors?
    See
    Decompiling ADF Binaries: Customizing Business Components Error Messages
    :http://www.adftutorials.com/adf-custom-error-handler-to-display-custom-message-to-user.html
    Frank

  • Execution of entity validation multiple times (adf bc 10g)

    Implementing entity method validators sometimes causes the validation (e.g. validateEntity method) to execute multiple times. We have figured out that this case occurs when we call method setAttribute programmatically when we implement business rules on the entity level. For example in many cases that we want to enforce dml operation execution, we override the method prepareForDML so that the framework works as follows:
    •     calls validateEntity, validates entity for the first time
    •     calls prepareForDML –> setAttribute this method invalidates the entity row
    •     calls validateEntity, validates entity for a second time
    I can understand that sometimes multiple entity validation is necessary and important, there are cases though that this behaviour is not necessary and additionally it degrades performance especially when we utilize sql queries inside the validation (as it executes the queries multiple times).
    Is there any workaround to avoid multiple execution of entity validation or enforce the validation to occur only once, for example after the prepareForDML method and not before?
    Edited by: user647567 on 9 Σεπ 2010 6:58 πμ

    Hi there:
    I don't think JDeveloper provides a switch to bypass the Entity Validation. Too much meddling. MVC model has those layers and advocates reducing unnecessary dependencies between layers. Entities and Views are both in Model layer though. But you can build a view without an Entity and vise versa you can have an Entity that doesn't have default views. So my understanding is the Entity Validation is quite necessary.
    Though from View layer, on a jspx page, you can use command buttons and set their "immediate" property to "true" to bypass form validation temporarily and postpone it to form submission time.
    My understanding for Entity validator is they should be light weighted. You properly should avoid SQL queries directly in them. Instead you should use EntityImpl or ViewObjImpl/ViewRowImpl instead of SQL queries directly in validator.
    If you feel my answer helpful to you, please mark it so.
    Thanks,
    Alex
    Edited by: Alexbie on Sep 9, 2010 11:11 AM

  • MDG Cross entity validation using enrichment spot is not executed.

    I have configured the enrichment sport for cross entity validations and used BRF to validate the data, but looks like validations are
    not executed. I have the check activated for the step in the configuration and I can see my custom class is being picked in method GET_ENRICHMENTS of class CL_USMD_DQ_ACCESS_ENRICHMENT for that request type and step. I have flag relevant  selected and option “Execute Always” (will change this to “Execute when data changed).
    I am trying to figure out if SAP MDG standard code will execute my custom class code or not. I had put break point in my custom class constructor and this is called when an instance for enrichment is created in method GET_ENRICHMENTS of class CL_USMD_DQ_ACCESS_ENRICHMENT. However my code in below method is not executed (and hence BRF is not called)
      IF_USMD_ENRICHMENT_FEEDER~GET_ADAPTER_DATA
      IF_USMD_ENRICHMENT_FEEDER~IS_RELEVANT
    Now I am trying to figure out a place from where these enrichment class methods will be executed. I feel this will be from EXECUTE_ENRICHMENT
    of class CL_USMD_DQ_ACCESS_ENRICHMENT. But this method is also not executed when I hit on Check button. Am I looking wrong standard class?
    Is there anything I am missing in configuration? Or we need to implement any SAP note? I tried to find one, but no luck.

    Hello, I am not using cress entity BADI for Validation. I am using this BADI for cross entity derivations and they are working fine.
    I had a requirement to do cross entity validations, and I have rules written using the BRF+.
    I had used enrichment sport functionality to have a custom class used to call BRF functions and prepare the context with required entity data.
    Validations are supposed to happen based on the enrichment spot defined and the configuration for that enrichment sport on the process step level. This is not happening. let me know if you need more information on it,

  • Automatic entity validation

    Hi
    We are building an application framework on top of Toplink. One thing we added are field validators that are called on every setXXX(). The validator throws a ValidationException if there is a problem. This is automatic, and the developer doesn't need to care about it. ValidationException are atomaticaly sent back to the form by the framework and displayed using a message pool system...
    Now, we want to add an automatic entity validation system. The idea is to call the validate() method on the entity during the commit of the unit of work. The validate() method performs entity wide validations and throws a ValidationException if the entity is not valid. Of course, the framework must rollback the transaction if needed.
    How can wee do that in Toplink? I thought that events could help us, but I don't think we can throw exceptions from there...
    Any idea?
    Thanks
    Regards
    Eric

    Just to clarify,
    If you add this validation to your status attribute then it will validate that Reason is not null when you change the status to 4.
    If you want to raise an entity validation just add a new Entity Validator and the expression should be something like what you had:
    But slightly different
    Status != null ? (Status==4? (Reason!=null) : true) : true

  • HELP: ADF-Error in Entity Validation - Validation fires twice

    Hi there,
    I have problems with the entity validation in JClient when I have more then one UI-Element that references to the same Data Control / Model Attribute within one panel.
    E.g. I have a table where I display all customers. Above the table I show detail information with editable JTextFields for the customer I've selected in the table. When I change the name of a customer and leave the textfield, the new Value appears also in the table. Thats all ok.
    The problem:
    The entity validation fires twice in that example. E.g. when I insert 30 characters in the name field, but the corresponding database column only stores 20 characters, the
    displayed exception appears twice. When I remove the textfields from the panel
    and edit the values direct in the table, the validation only fires one time.
    How can I avoid that behaviour? I have a lot of screens where it is important to show the list of objects in a table and let edit specific data via text fields.
    That behaviour is also reproducable with the ADFJClientComponentDemo
    (Jtree binding demo). If you insert more characters than allowed in the firstname field,
    the Exception Message is shown twice.
    Thanks for your help,
    Claus

    Hi Fred,
    It's nice to know that somebody out there uses the same technology in a similar way.
    Our L & F is also JGoodies based (we didn't use JGoodies forms).Yes, nice to know. We also only use L&F and not the JGoodies Layout Manager
    (but if JDev 10.1.3 provides that layout manager maybe we use it for new panels).
    In our JClient View project, we used very few try/catch blocks, mostly in our custom
    Navigation bar class (with freeze row function).
    How would you translate the following in 3tiers?
    in the client class:
    try {
    // call a method in the model
    catch (JboException je)
    this.getPanelBinding().reportException(je);
    }We don't use any try/catch-blocks to check for model-exceptions.
    In our application a typical bootstrap code snipplet looks like that:
    =======================================
    //As classmember we have our own ErrorHandler:
    protected HTOErrorHandler errorHandler = new HTOErrorHandler(true);
    //some bootstrap code
    BindingContext ctx = new BindingContext();
    ctx.put(DataControlFactory.APP_PARAM_ENV_INFO, new JUEnvInfoProvider());
    ctx.setLocaleContext(new DefLocaleContext(null));
    //Set Custom Error Handler
    ctx.setErrorHandler(errorHandler);
    =======================================
    Our Custom Error Handler Looks like this:
    =======================================
    public class HTOErrorHandler extends DCErrorHandlerImpl
    boolean inReportException = false;
    public HotErrorHandler(boolean setToThrow){
    super(setToThrow);
    public void reportException(DCBindingContainer bc, Exception ex){
    disableAppendCodes(ex);
    showPopup(ex);
    super.reportException(bc, ex);
    private void disableAppendCodes(Exception ex){
    JboException jboEx = (JboException) ex;
    String baseMsg = jboEx.getBaseMessage();
    String detailMsg = jboEx.getDetailMessage();
    String errorCode = jboEx.getErrorCode();
    Locale defaultLoc = Locale.getDefault();
    Object[] detailExceptions = jboEx.getDetails();
    if ((detailExceptions != null) && (detailExceptions.length > 0)){
    for (int z = 0, numEx = detailExceptions.length; z > numEx; z++){
    disableAppendCodes((Exception) detailExceptions[z]);
    public void showPopup(Exception ex){
    DialogMessage dialog = new DialogMessage((JboException)ex);
    dialog.setVisible(true);
    =======================================
    The DialogMessage is our own ModalDialog to show the ErrorMessages with
    a userfriendly dialog (e.g. we show some error/warning/info-icon...)
    Each time we throw a exception in a EntityObject the framework ensures that
    the Message is shown in our own ModalDialog without using try/catch-blocks
    and the this.getPanelBinding().reportException(je)-method;
    We wrote our own ModalDialog because of L&F-reasons. But you said that
    you use the Standard-Dialog. IMHO you must neverlethess use the setErrorHandler-Method
    in 3-tier mode, but you needn't to write your own ErrorHandler, you can use the
    JUErrorHandlerDlg....
    The following line of code is generated by the ide when creating a default form:
    app.getApplicationModule().fetchAttributeProperties(new String[] {"Test2View1"}, new >String[][] {{"Id2", "Name2", "Id3", "AttrTest"}}, null);
    I read somewhere that when opening a panel, one should call that method for all used >properties in 3tiers mode only.Sorry, but we don't currently optimize something like that. For what reason
    do you want to call that method explicit? We don't have a custom method for that.
    I add tests in the validateEntity method and throw a JboException.
    I suppose for 3tiers I will have to replace throw new JboException by ???? No. You don't have to replace that. The framework notifies your client via the registered ErrorHandler.
    So when a mandatory field is empty, the framework displays an error when a commit
    or navigation event is triggered in the nav bar and the user has always access to that
    field.We want to override the default framework message with our own message. So we have
    to throw the exception manually at some point in the entity object. And for that reason
    we implemented a custom validation via MethodValidator, but the framework-validation fires
    an exception BEFORE our custom validation is processed. Maybe you don't have that problem
    because you use the default error messages. Do you use deferred Exceptions? We do so.
    Did you try JClient 3tiers deployments over the Internet?Yes, we tried it via VPN/DSL to validate that our framework interface-usage works both in 2-tier and 3-tier.
    After several attempts we were successfull, but the performance was poor.
    PS Are you connected to skype? Unfortunately no because of firewall restrictions. We only have access to ICQ.
    Regards,
    Claus

  • More Entity Validation problems

    I have 2 screens each based on different entities.
    I seem to get problems when i do the following:
    1) enter correct data in the first screen. Hit submit and correctly move to the second screen
    2) Enter invalid data in second screen, and press submit. At this point the entity validation kicks in and I display the problems.
    3) The user hits the back browser button.
    4) They change information in the first screen and hit submit.
    5) At this point the entiity from the second screen(which contains invalid data) validates again.
    6) Because there are errors in this second entity I can't get pass the first screen again.
    Is this standard functionality ?
    What am I doing wrong ?
    I'm using jdev 9.051 jsp/struts/adf.
    The only solution I have is to move the validation code from the entity to my struts action, but will only do this as a last resort !!

    Clicking the back button, doesn't clear the second entity and therefore it will still fail the validation.
    The user shouldn't click the back button, instead you should supply a "Cancel" button in the second page that will then clear the information that was entered in that screen and will navigate to the first form.

  • Entity validation across multiple pages

    Hi,
    I have an entity that spans multiple pages and are wondering how I can get the entity validation to work one page at a time. Currently if I have mandatory attributes that are not shown until the second page I receive errors from the first page stating that these muist be entered.
    My current thoughts on fixing this is either to change my model to on epage per entity, or to turn of entity validation (including mandatory attributes) and just do my validations in my struts actions.
    This is a Jsp/ Struts / ADF BC project.
    Many Thanks,
    Richard

    Leo,
    I'm not sure I would have done this with columns. Because of your desire to link from one piece of text to another, in all three columns, I would use linking text boxes. Each of the three boxes on a page will be independent of each other, but can be linked to the boxes on the following pages. Does that seem like what you're looking for?
    -Dennis

  • Entity validation (Urgent)

    In my validateEntity call, how do I call a set method for an attribute that belongs to another entity?

    Just to clarify,
    If you add this validation to your status attribute then it will validate that Reason is not null when you change the status to 4.
    If you want to raise an entity validation just add a new Entity Validator and the expression should be something like what you had:
    But slightly different
    Status != null ? (Status==4? (Reason!=null) : true) : true

  • Entity validation with groovy expression

    Hi,
    I'm using jdeveloper 11.1.2.3.0
    I have an entity object with two attributes "status" and "reason".
    Only in case the user select status id "4" I would like to validate that he will select also reason.
    for this I was trying to add entity validation with groovy expression.
    so I added this expression "Status== 4 && Reason == null" and also I added failure message.
    But it doesn't work as I expected.
    The error is displayed every time, also when the user select status that is not 4 and also when he select status 4 and the reason is not null.
    How should I write this groovy expression?
    Thanks

    Just to clarify,
    If you add this validation to your status attribute then it will validate that Reason is not null when you change the status to 4.
    If you want to raise an entity validation just add a new Entity Validator and the expression should be something like what you had:
    But slightly different
    Status != null ? (Status==4? (Reason!=null) : true) : true

  • How to refresh View bind variables or is this a bug in Entity Validation?

    Maybe I am missing something. Here is the scenario:
    1. I got a create/edit form with a field (*tfA*) that is a af:selectInputText that launches a search form pop up.
    2. The form (which is tied to an Entity ADF object) has validations -both attribute specific and global (for lack of better term..) set up in the Entity Object Editor wizard.
    3. I noticed that when a global validation fails, when i launch the search form from tfA, it ignores whatever search criteria I enter (ie it retrieves all rows)
    Otherwise, the pop up search form works perfectly. I am wondering if I need to reset the bindVariable values somewhere or if it has something to do with a refreshCondition. What confuses me though is that it works just fine if the global (ADF Entity) validations don't fail.
    The pop up search form uses the default ExecuteWithParams action listener that calls a view with bindvariables. My JDev version is 10.1.3.4
    Any help is appreciated. Thank you.

    The issue turns out to be that the Global Entity Validation continues to fire even after you click on the find button on your selectInputText component. The Entity validation is interrupting the call to the View Object in my pop up search window because somehow clicking search on the pop up is submitting the originating form.
    I am still not sure if this is a bug that needs to be addressed or I was doing something odd but the solution is the following:
    in your *<af:selectInputText />,* add the following: *actionListener="#{bindings.Rollback.execute}"*
    This will prevent the validation from firing because it thinks that you are trying to submit the form when all you're doing is actually launching a search pop up.
    Hope that helps.
    Edited by: rrey on Aug 3, 2009 3:58 PM

  • Entity validation strange behaviour

    I have a number of method validators against an entity.
    The validators fire for incorrect data entered on the associated screen and once the data is fixed the user is presented with a second screen. All is fine so far ...
    Until the user hits the back button to go back to the first screen. For some reason even though the user enters invalid data the method validators don't fire !!!. Very confusing.
    Does anyone know of any reasons why this should occur ?
    Many Thanks,
    Richard

    Hi,
    I added a page-link to my second page as suggested. Using this method(instead of back button) causes the validation in the first screen to re-fire.
    The previously entered values in the first screen are gone as its a new request.
    I use code from your toystore to pre-create a record in the initializeModelForPage step. This fires when the link is clicked, and part of that code deletes the last entry from the entity cache. Therefore I'm not too surprised this works. As part of this project it has been stated that the users should be able to navigate through the browsers buttons, so I'm still abit stuck. Any suggestions ?
    What i've done for now is to remove my validation from BC4J to my struts actions.
    But because new values aren't recorded in the entity after a back button I also have to manually set the bindings for each screen field in my struts action.
    I'm not an expert in the adf / struts frame work so I could just be missing something.
    On a related point(assuming that i use entity validation) the following happens.
    On my first screen I enter valid data , and then move to my second. I leave the screen in an invalid date before pressing the browsers back button. I then can't get past the first screen as it is still validating the errors in the second screen. Shay mention that I should be using a cancel button in the second screen to navigate back to the first. This is a public user application and I know that the back button will be pressed(its not good web design to remove/disable it anyway).
    Any suggestions.
    It seems that I can't get the ADF framework to work well with wizards and perhaps its best to just use struts for the validation and at the end of the wizard just call a database package to do the DML ?
    Sorry but one last point - to do with the refresh button.
    All my wizards use page forwards to move between screens and I know this can cause oddities with a refresh. What I have noticed is that when even refreshing the first page of my wizard(after leaving it in an invalid state) the screen doesn't change the errors are still there. I would have though the refresh would request a new refreshed page without the struts action errors. I even noticed that a refresh can cause a struts action related to a submit button to re-fire ? Why does this happen as it can cause a big mess.
    Even re-entering the url in the same browser window doesn't cause the screen to properly refresh. The initializeModelForPage steps also do not fire when a refresh happens. I did notice that if I went to a different website and then re-entered the url that the page displayed more as expected and I think the initializeModelForPage step ran.
    I'm sure alot of this is due to the fact that I don't really understand the framework, and thus would be grateful if you could explain why all the above happens. Is it what you would expect to happen ?
    Many Thanks for your time and assistance.
    Richard

  • Special character Validation: error

    HI Guys,
    I wrote a validation to restict the use of special chracters.
    Its a formula based validation, both REAL TIME and BATCH, on the Node.
    HasCharacters(Custom.EPMA_Alias, ["]).
    However, when I go to put an Alias on a member, it tells me there is a special character in this, but there is not.
    I also tried HasCharacters(PropValueCustom.EPMA_Alias0, ["]) with same results.
    I also need to add the following characters:
    |
    Thank you for all your help!.

    Hi,
    DRM will not support the syntax ["], instead try somethinug like this for your validation logic-
    And(
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),|,,T))),
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),",,T))),
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),%,,T))),
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),*,,T)))

  • Insert into viewobject in app module does not show entity validation errors

    Hi everybody,
    I am using JDeveloper 10.1.3 and ADF BC/ADF Faces. I want to have a button on one of page and I want that whenever user clicks on this button a records is inserted in a table. so I created an application module service method and exposed it on the client interface and the put it on my page using Data Controls Tab.
    Here is some part of my code in application module :
    public void setMember() {
    HrMembershipsViewImpl membershipView = (HrMembershipsViewImpl)am.findViewObject("HrMembershipsView1");
    HrMembershipsViewRowImpl newRow =(HrMembershipsViewRowImpl) membershipView.createRow();
    newRow.setAttribute("MemberId",memberID); //this.getCode());
    newRow.setAttribute("MembState","1");
    newRow.setAttribute("CardState","1");
    membershipView.insertRow(newRow);
    trans.commit();
    When this method tries to insert a record which violates a validation rule in the Base Entity Object, the screen does not show any error regarding to violating the business rule but nothing is inserted. I changed my code and captured the exception around the commit and I found that a JBO-27023 Exception happened after commit ( which was very surprise since the page does not show any error).
    Now I can change my code to to the following to show that error happened.
    public void setMember() {
    try {
    trans.commit();
    catch (JboException ex) {
         getDBTransaction().rollback();
         throw new JboException ("There is an error during commit");
    throw ex;
    But I believe it shouldn't be like this. Normally, we should be able to insert programmatically in a view and if the business rules are violated we should get the violation error messages. If I use the above mentioned method we can not understand what business rules are violated.
    Does anybody know what is wrong with my solution? I have seen a lot of times that using application module is the best way for adding functionality to the application pages but I really feel that something should be wrong if we can not get business rule violation messages.
    Any help or references would be highly appreciated.
    Thanks in advance,
    Navid

    Hello Navid,
    it should work without try-catch.
    1. When you add try-catch, does your error message appear on the page?
    2. Does your page contains af:messages component?
    3. Does your button have any navigation to another page?
    Rado

  • Keep the old value in the UI field if entity validation fails

    Hi,
    I have a requirement to retain the original value (old value), if the entity attribute validation fails when the filed value is changed. I have created one validation rule on the entity object and the validation rule is working as expected. But I would like to reset the value to the original value if the validation fails on the modified value.
    Thanks and Regards,
    S R Prasad

    Hello,
    Please tell us your first name, and change your forum handle to something more friendly than User123. It’s nicer and easier for us this way.
    It seems that the forum software messed up the example code you wanted to present. To avoid that you can use the forum tags &#91;code] and &#91;/code] at the beginning and end of your code.
    If I understand correctly, you are trying to retrieve the original field value from a fxx array, however these arrays are populated after page submit, so they don’t hold the initial values of the column.
    I think the simplest solution will be to use an ‘onfocus’ event that will save the initial value – this.value – in a global JavaScript variable. In your ‘onchange’ code, instead of clearing the field if validation failed just assigns the original value for the JavaScript variable.
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Forthcoming book about APEX: Oracle Application Express 3.2 – The Essentials and More

Maybe you are looking for

  • Debug IP error help

    Gurus, Using Ciscoview to monitor our 3750 switch, I noticed high IP error counts. After connecting to the box and issuing the "debug ip error" command the following output was displayed: "datagramsize=92, IP 27444: s=192.168.1.100(Vlan1), d=192.168.

  • Updates Keep Freezing on Configure Installation

    Hi, I am having a problem with my updates on my mac mini. I am running 10.5.2. The problem I seem to be having is that when I try to install my updates, for example the new Safari and security update. It will download and tell me I have to restart my

  • Report Writer Row and Column Format

    Hi Was wondering if there is a possible solution to this :- Understand that column format is controlled by format groups. This means that all figures in the same column will take the same format (such as scaling and decimal place). Scenario is ->    

  • Nokia 5800XM The Pencil

    Hi All also got a nokia 5800 XM and it seems mine is working fine and never got any problems yet nor aware of. im a bit expecting all of it. hehe My problem is here, i heard this pencil application and was able to download it through a wifi connectio

  • Meaning of RFC and web services

    Experts,    Can anyone explain the basic meaning of RFC and webservices.What do u mean by RFC call etc.When do we use webservices and what are the advantages of using this? I will not disappoint any  expert. Thanks Veeru