Forum Stats

  • 3,875,729 Users
  • 2,266,956 Discussions
  • 7,912,321 Comments

Discussions

Validate Attribute value at entity level validation against Runtime DB Query

2»

Comments

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,930 Red Diamond

    Sanjeev, I'm not sure what to do with the test case. I don't see any description on how to get to the problem. Please tell me what to do.

    From what I see in the sources, you don't get any exception because there is no rule defined for your transient attribute.


    Timo

  • Sanjeev-OFM
    Sanjeev-OFM Member Posts: 411 Bronze Badge
    edited Sep 14, 2022 6:26AM

    Hi Timo,

    Actually having two attribute EName which is db attribute on this if I'm putting validation either on attribute or entity level it's showing the message properly.

    but if the same validation i'm applying on transit attribute EMPName (which is based on EName ) is not triggering any validation neither at entity level nor at attribute level and not showing any message.



    Kindly suggest, how i can trigger the validation on transit attribute.

    Thanks

    Sanjeev

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,930 Red Diamond

    Sanjeev, your data model is OK, but the rules you try to implement are not. You can't implement a rule that the data in the DB is not fulfilling. The transient attribute EMPName should be one of the department names from the dept table but must be equal to the emp_name attribute of the employee. This rule is not valid in the data you added to the DB.

    So, your test case can't be used to show anything. A test case should show the problem but should not be the problem.

    If you remove the emp_name setting from the transient attribute and add a rule that checks if the value entered by the user is a known department name (from the list rule), it works as expected.

    Timo

  • Sanjeev-OFM
    Sanjeev-OFM Member Posts: 411 Bronze Badge

    Hi Timo,

    Thanks for the information and yes you are right in this way we can do the transit attribute validation.

    Actually as we need to validate one of the DB attribute which hold 8 combined value ie.("001.100.101.00012.ABC123,24343,12019,ak200") and we need to validate starting 4 value ie.("001.100.101.00012") with other query result so to achieve this declaratively I thought to have 1 transit attribute and compare the value with query result but somehow it's not working so thought to check.

    Please suggest if there is any other way to achieve this using declarative approach.

    Thanks

    Sanjeev

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,930 Red Diamond

    Well, I remember that I told you to do this in the DB already.

    Sure, you can use a transient or original attribute and compare it against something else. But why do you want to do it declarative?

    You need to extract part of the original value and compare it. This you don't do declaratively. Use either a groovy expression or use a method validator.


    Timo