Forum Stats

  • 3,875,708 Users
  • 2,266,953 Discussions
  • 7,912,310 Comments

Discussions

Validate Attribute value at entity level validation against Runtime DB Query

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

Hello Friends,

We are having one requirement where we need to do additional validation against a query text. I'm explaining it with the scenario.

Scenario:

We have to validate entity based view object one String attribute value (which is a combination of 8 multiple values separated via "." Value example-- "001.100.101.00012.ABC123,24343,12019,ak200") against with query text where starting 4 parameter value of String attribute need to pass in query text where clause( select count(*) from table name where param1='001' and param2='100' and param3='101' and param4='00012') and if query text count>0 than allow to save the record and if there is no record with provided combination in query text than need to show error message.


Kindly help with suggestion how we can validate it using the declarative approach.

Thanks

Sanjeev

Tagged:
«1

Comments

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

    Hello Friends,


    Any Suggestion??


    Thanks

    Sanjeev

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

    User, tell us your exact JDev version, please!

    I don't see any chance to do this declaratively.

    You can do this as a groovy script or a java business rule in the VO/EO.


    Timo

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

    Hi Timo,

    Thanks for the update jdev version is 11.1.1.9.0.


    Thanks

    Sanjeev

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

    Hi Timo,

    Using groovy script can we validate it with the querytext result, if so please help with some information?

    Thanks

    Sanjeev

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

    On second thought, I would do it in java as a business rule. This way you are free to use pl/sql or other methods to help you implement the validation.

    Using groovy limits you somewhat, e.g., you can't easily call other methods from different objects like AM or other VOs.


    Timo

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

    Hi Timo,

    Thanks for the information, want to check one more thing, where we can have this validation in EOImpl.java file or in backing bean, Which one will be the best suggestable approach?

    Kindly suggest.

    Thanks

    Sanjeev

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

    The rule of thumb is to install validations at the EO level. This ensures that every data written to the DB has been validated. ADF uses this approach but adds some client-side validation too (e.g. checking for numbers). Still, all data written to DB tables should be valid.

    As a DBA I would enforce the final validation in the DB using constraints. In the end, users expect to see valid data in the DB and a DBA will not trust anybody but the DB.

    I would implement the validation in the DB (that's the DBAs work) and on EO level.

    Timo

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

    Hi Timo,

    Thanks for the information, want to check can we do the transit attribute level validation in Enitiy Object at attribute level or at entity level.

    Please suggest.


    Thanks

    Sanjeev

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

    You can do both. It depends on the use case. If the attribute can be tested without knowing other values from the same EO (or other EOs), you can do it at the attribute level. If the attribute needs information from other attributes of the same EO, it's better to do an entity-level validation. This way, you know that all attributes are given (have the values the user wants to store), and the validation must fulfill the rule.


    Timo

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

    Hi Timo,

    Thanks for the information, I'm having one transit attribute(EMPName) which is based on other db attribute(Ename) of Entity Object.

    Here when I'm doing the entity level validation on db attribute(Ename) it's performing the validation and showing the error message properly but when I'm doing the same validation on transit attribute (which is based on db attribute using groovy). I've assign the Ename db attribute value to EMPName transit attribute) the validation is not getting triggered and not showing any validation message.

    Jdeveloper version is 11.1.1.9.0.

    Kindly suggest.


    Thanks

    Sanjeev