How can I use database constraints in entity attribute validation rules

I am interested in using database constraints to validate attributes in entity objects.
I would like to implement a JboValidatorInterface in a way that I can use an operator like "GreaterOrEqualTo" to compare with values retrieved from the database for a column associated with an entity object attribute.
I have used this pattern with success in other environments, where the user community decides the minimum value for a thing should change from x to y, and simply changing a database object also changes the validation methods of all applications which access it.
I am not certain that column constraints are the appropriate vehicle, but so far that seems to be the case.
I see that you can create a validation rule which makes comparisons against a view object attribute. I am wondering if there is a generic way to use standardized names for column constraints along with ADF hooks into properties of database columns, to avoid writing individual queries for each attribute.
Thanks in advance!!!

Jeffrey,
If you already have constraints on the underlying tables, why do you need to validate them in ADF BC? You can certainly use some framework extension classes to give the user nicely formatted error messages - see ER: ADF BC - allow custom error msgs for common exceptions (e.g. DML) for more details.
I am using this method so that anything that is enforced in the database (check constraints, foreign keys, unique constraints, etc) are not enforced in the ADF BC layer as well - after all, there's more than one way to get data into a table, and DB constraints ensure that even if data gets in through another mechanism (apart from the ADF application), it is valid. My 2 cents, of course.
Hope this helps,
John

Similar Messages

  • How can i use JSTL inside custom tag attribute

    Hi,
    I have one button tag which displays the button with round corner. I will show the button like this:
    <ep:button key="buttons.submit" name="submitBtn" styleClass="But"
              onClick='submitPage(''<c:out value='${buttonName}' />)' />
    I am getting the problem with the above code. how can i use JSTL inside the custom tags.
    Thanks in Advance,
    LALITH

    No. The details are given below:
    I have included the follwing line in web.xml file:
    <taglib>
        <taglib-uri>/tags/button</taglib-uri>
        <taglib-location>/WEB-INF/button.tld</taglib-location>
      </taglib>button.tld file
    <taglib>
         <tlibversion>1.0</tlibversion>
         <jspversion>2.0</jspversion>
         <shortname>button</shortname>
         <tag>
              <name>button</name>
              <tagclass>com.ksi.ep.web.taglib.ButtonTag</tagclass>
              <bodycontent>empty</bodycontent>
              <attribute>
                   <name>name</name>
                   <required>true</required>
                   <rtexprvalue>false</rtexprvalue>
              </attribute>
              <attribute>
                   <name>key</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
              <attribute>
                   <name>onClick</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
    </taglib>ButtonTag.java :
    public class ButtonTag extends TagSupport {
       private static final long serialVersionUID = 6837146537426981407L;
         * Initialise the logger for the class
        protected final transient Log log = LogFactory.getLog(ButtonTag.class);
         *  holds the Value of the button tag
        protected String onClick = null;
         *  holds message resources key
        protected String key = null;
         * The message resources for this package.
        protected static MessageResources messages =
                             MessageResources.getMessageResources
                                       ("ApplicationResources");
          *  (non-Javadoc)
          * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
         public int doStartTag() throws JspException {    
            StringBuffer label = new StringBuffer();         
            HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
            try {             
                   log.debug("in doStartTag()");
                   Locale locale = pageContext.getRequest().getLocale();
                 if (locale == null) {
                     locale = Locale.getDefault();
                 log.info("");
                 label.append("<a border=\"0\" style=\"text-decoration:none;color:#FFFFFF\" href=\"JavaScript:");
                 label.append(onClick);
                 label.append("\" >");
                   label.append("<table  onClick=\"");
                   label.append(onClick);               
                   label.append("\" ");
                   if(onmouseout!=null && !"".equalsIgnoreCase(onmouseout))
                    label.append(" onmouseout=\"");
                    label.append(onmouseout);               
                    label.append("\" ");
                   if(onmouseover!=null && !"".equalsIgnoreCase(onmouseover)){
                    label.append(" onmouseover=\"");
                    label.append(onmouseover);               
                    label.append("\" ");
                   if(title!=null && !"".equalsIgnoreCase(title)){
                    label.append(" title=\"");
                    label.append(title);               
                    label.append("\" ");
                   label.append("style=\"cursor:hand\" tabindex=\"1\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"");
                   label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));
                   label.append("background1.jpg\" > ");
                 label.append("<tr><td width=\"10\"><img  border=\"0\" src=\"");
                 label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));
                 label.append("leftcorner.jpg\" ></td> ");
                 label.append("<td valign=\"middle\"  style=\"padding-bottom:2px\"><font color=\"#FFFFFF\" style=\"");
                 label.append(styleClass);
                 label.append("\">");
                 label.append(messages.getMessage(key));
                 label.append("</font></td>");
                 label.append("<td width=\"10\" align=\"right\"><img src=\"");
                 label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));            
                 label.append("rightcorner.jpg\" border=\"0\"  ></td>");
                 label.append("</tr></table></a>");
                 pageContext.getOut().print(label.toString());
              } catch (Exception e) {               
                   log.error("Exception occured while rendering the button", e);
                   throw new JspException(e);
            return (SKIP_BODY);
         * Release all allocated resources.
        public void release() {       
            this.name=null;
            this.key=null;
            this.onClick=null;
    }In my JSP I have mentioned the taglib directive as
    <%@ taglib uri="/tags/button" prefix="ep"%>and
    <ep:button key="buttons.submit" name="submitBtn" styleClass="But"
         onClick='overwritePreApprovals('<c:out value='${transactionalDetails['inPrepList']}' />')' />Servlet.service() for servlet action threw exception
    org.apache.jasper.JasperException: /pages/pms/coordinator/Dashboard.jsp(325,48) Unterminated <ep:button tag
    Thanks,
    LALITH

  • How can I use sequences in BC4J

    Hello!
    I read in BC4J documentation about how can I use database sequences to generate next value with BC4J. My question is:
    If I don't want to use DB seq what can I do? We have DBSequence class. I look into it and see there not only a DB seq allowed.
    Can anybody help me? I don't want to use DB sequences.

    Don't quite understand the question. If you don't want to use DB sequences, then just override the create() method in your entity object and use call a setter method to set the attribute ID to what you want if you want to do this in an "eager" way that the user would immediately see in a newly-created row...
    ...or you can write code in an overridden prepareForDML method if you want to set a value for one or more attributes just before the changes are posted to the database.

  • How can I use two database in Dataset in SSRS?

    Hi,
    I am using one query to generate my SSRS report. In that query I am using subquery. Now I am pulling data from multiple tales.
    DB used in sub query is different than the rest of the tables DB.(So total I am using 2 DB(Database))
    So I see that in SSRS, I can connect query(In DataSet Properties) to one DATA_SOURCE only, how can I use other database which is I used in sub-query?
    I have to move this SSRS into PROD and I can't hard code that sub-query's DB name in my query.
    Please give me suggestion. Thanks!!
    Vicky

    In SSRS 2008 R2 you can use the Lookup function (http://technet.microsoft.com/en-us/library/ee210531.aspx ) and LookupSet function (http://technet.microsoft.com/en-us/library/ee240819.aspx
    Depending on your security set up, you can reference a table in a second database on the same server using a three part name:  database.schema.table.  This is more likely to work for you if you wrap your SQL command in a stored procedure.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How can i use Unix database in java?

    How can i use Unix database in Java?
    Message was edited by:
    JPro

    I have not a clue about FoxPro, but the db then is FoxPro and not Unix. The better question would be "How do I connect to FoxPro DB running on Unix with JDBC?".
    My answer to that would be, search the Internet for a JDBC driver.

  • How can i use offline & online database in the same time?

    how can i use offline & online database in the same time?
    my database in another server when the connection true it connect
    but if not does not work
    i wanna make offline database if the server not connected it connect offline then the server is on it alter all data from the offline to the server.

    User, please tell us your Jdev version!
    There is no such functionality build into the framework. The offline data base is only for designing the db, not to have a backup db.
    If you can't connect to the db the application will not work.
    Timo

  • How can i use diffrent database for same file in same project?

    I want to use two database. First normal environment, second for budget. Second copy from first environment. For example 1. database name = "MRP" , 2. database name = "MRPBUDGET".When program is start, users can select database. My question how can i use which selected database name in program.
    Thanks a lot for your help,

    Hi giri,
    I test it. When i change
    cocukRowSet.setDataSourceName("java:comp/env/jdbc/mysql_dogum");
    cocukRowSet.setDataSourceName("java:comp/env/jdbc/mysql_dogum1");
    in SessionBean1.java
    i run it. But this page of project is open explorer it didn't change sun-web.xml and web.xml in projetct directory(line
    <resource-ref>
    <res-ref-name>jdbc/mysql_dogum</res-ref-name>
    <jndi-name>jdbc/mysql_dogum</jndi-name>
    </resource-ref>
    When i close this page of project from explorer , i clean and build project and then find in project "dogum1", i saw true value in sun-web.xml and web.xml. Project is running true.
    How can i change xml file when project running. Can i use drop down list for database name(which change run time)
    Thanks,

  • How can I use File DSN to connect to database?

    Hi,
    I am using ODBC-jdbc driver to connect to the database. It seems that the DSN name is required. How can I use a file DSN instead of system DSN to connect to database? Please help?

    oracle provided jdbc drivers (thin and oci) do not use odbc.
    why would you want to slow things down by sending "round trip" data transfers thru a "jdbc to odbc" and thru "odbc to jdbc" conversion routines.
    It isn't necessary with the oracle provided drivers !!

  • How can I use a subsummary field in a calcultaion field in a database ???

    how can I use a subsummary field in a calcultaion field in a database???? I need to use the average I get in my sorted records to make another calculation. Can this be done???
    powerbook G4   Mac OS X (10.4.8)  

    Calculation fields work with data that is contained in a single record.
    Summary fields use data from the same field(s) in a range of records.
    Summary field results can't be used in further calculations.
    You may be able to define a summary field to include the average AND the further calculation that you need, but only if you do not want the results to be placed into a particular record or records.
    A detailed description of the data you want to use and the result you want to achieve might lead to some ideas on whether it can be done, and how to do it.
    Regards,
    Barry

  • How can I use jbo:InputSelect for a char type filed?

    How can I use <jbo:InputSelect for a char type filed?
    I have two tables. One is room (primary key is room(type is char)), another table is responsibility (foreign ker is room(type is char)). Both tables have same length for room column.
    There is a problem:
    If I use (in the "DataEditComponent.jsp" file)
    <jbo:InputSelect multiple="false" datasource="dsEdit" displaydatasource="roomData" displaydataitem="ROOM" displayvaluedataitem="ROOM" ></jbo:InputSelect>
    to get the room input for responsibility from combobox(Datasource roomData is from room table). In the form the room field cannot bind the data in combobox, alway select the first item. And if I select one item and click the update button.There is an error message:
    Error Message: JBO-27010: Attribute set with value H409 for Room in Responsibility has invalid precision/scale
    I found If I changed the field type from char to varchar2 in database also change the entity objects, it works well. I wonder if there are any diffrence using <jbo:InputSelect tag in char and varchar2 type. How can I use <jbo:InputSelect for a char type filed as i don't want to change my datatype in database at this stage.
    I try this in JDeveloper 9.03, 9.034, 9.04. The result is the same.

    If I were in your shoes, here's how I would do it:
    <%-- Assuming you have dsRoom and dsResponsibility --%>
    <%-- Select is an HTML tag --%>
    <select name="ROOM" size="1">
    <% char roomID =""; // Init your character var
    // Open a rowsetIterator to get the records and add them to the LOV
    <jbo:RowsetIterate datasource="dsResponsibility" changecurrentrow="true" >
    <% roomID = (char)dsResponsibility.getRowSet().getCurrentRow().getAttribute("ROOM"); // Grab the char value
    // add the value to the LOV
    %>
    <option value="<%=roomID%>"><%=roomID%></option>
    </jbo:RowsetIterate>
    </select>
    If you are using this as part of an edit page you may want to utilize the "selected" option of the <option> tag. In one instance I am doing this on an edit page because the use may open an existing record. If I don't account for it, then it will change the DB to contain the first value from the list! You can do a simple check like:
    //Set the current record's char
    char curRecord = (char)rowEdit.getAttribute("ROOM");
    // inside the iterate:
    if (curRecord == roomID) {
    <option value="<%=roomID%>" selected><%=roomID%></option>
    } else {
    <option value="<%=roomID%>" ><%=roomID%></option>
    Hope that helps!

  • How can I use TrueSequenceFactory with multiple sequences

    In the post "How to use existing Oracle sequences using KODO" answered
    by Marc Prud'hommeaux a "sample code" was given. But seems to me that
    example will only work with a single Oracle sequence for the entire
    system. Is this right?
    How can I use TrueSequenceFactory with primary-keys and their
    respective existing sequences? Can you (SolarMetric guys) provide me a
    sample code?

    The problem is that you are using application-identity. When you
    specify an objectid-class, we treat is automatically as application
    identity. To resolve this, I would recommend removing both the
    objectid-class and identity-type atributes from your class. With
    "objectid-class" in place, we asssume that you wil take care of identity.
    Eduardo Bobsin Machado wrote:
    I'm using Kodo 2.4.0, Oracle 9i, JBoss 3.0.4, the Kodo jars are in the
    JBoss' lib/ext.
    Well, I'll show what I have...
    This is the script of my table:
    CREATE TABLE LINEUP_VOYAGE (
    VOYAGEID NUMBER (10) NOT NULL,
    VESSEL_NAME VARCHAR2 (1000) NOT NULL,
    CONSTRAINT PK_LINEUP_VOYAGE
    PRIMARY KEY ( VOYAGEID ) ) ;
    This is an excerpt of my .jdo file:
    <class name="LineupVoyage" objectid-class="LineupVoyageId"
    identity-type="datastore">
    <extension vendor-name="kodo" key="table" value="LINEUP_VOYAGE"/>
    <extension vendor-name="kodo" key="sequence"
    value="LINEUP_VOYAGEID_SEQ"/>
    <extension vendor-name="kodo" key="pk-column" value="VOYAGEID"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="vesselName">
    <extension vendor-name="kodo" key="data-column"
    value="VESSEL_NAME"/>
    </field>
    <!--field name="id" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="VOYAGEID"/>
    </field-->
    </class>
    As you can see, the "id" field is commented.
    And this is my class:
    package br.com.fertimport.entity;
    import java.util.*;
    public class LineupVoyage {
         private String vesselName;
    //     private long id;
    //     public LineupVoyage(long id) { this.id = id; }
    //     public long getId() { return id; }
    //     public void setId(long id) { this.id = id; }
         public String getVesselName() { return vesselName; }
         public void setVesselName (String vesselName) { this.vesselName =
    vesselName; }
    The "id" attribute is commented.
    Now the questions...
    To use ClassSequenceFactory must the identity-type of my entities be
    application or datastore?
    Is the "objectid-class" parameter required in this case?
    As you see, all references to the "id" property are commented. Can I
    use this property to represent my object id?
    If not, how can I identify my object with something like a long?
    The last question is related to my architecture: one VM with the EJBs
    (entity and session) and another VM with the web classes and JSPs,
    connected by a session facade. I don't want to use any Kodo or JDO stuff
    in the web tier. Is this possible?
    Stephen Kim
    [email protected]
    SolarMetric, Inc.
    http://www.solarmetric.com

  • How can I use EJB component on Weblogic 8.1 server ?

    hi,dear sir:
    How can I use EJB component on Weblogic 8.1 server ?
    It need client jar to invoke ejb,but what will I to do for this jar file? what does it contain? format ?
    If my EJB module contain 100 session bean and 50 Entity bean,but I want invoke 20 session beans in my module, how can I to do?
    thank you...

    Hi,
    This forum is exclusively for Creator. please post this on appropriate forum
    regards
    CreatorTeam

  • How can I use the Rownum/Customized SQL query in a Mapping?

    Hi,
    * I need to use a Rownum for populating one of the target field? How to create a mapping with Rownum?
    * How can I use an Dual table in OWB mapping?
    * Can I write Customized SQL query in OWB? How can I achieve this in a Mapping?
    Thanks in Advance
    Kishan

    Hi Niels,
    As I'm sure you know, the conundrum is that Reports doesn't know how many total pages there will be in the report until it is all done formatting, which is too late for your needs. So, one classical solution to this problem is to run the report twice, storing the total number of pages in the database using a format trigger, and throwing away the output from the first run when you don't know the total number of pages.
    Alternatively, you could define a report layout so that the number of pages in the output is completely predictable based upon, say, the number of rows in the main query. E.g., set a limit of one, two, ... rows per page, and then you'll know how many pages there will be simply because you can count the rows in a separate query.
    Hope this helps...
    regards,
    Stewart

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • How can I use a bad IMEI AT&T iphone 5 with straight talk ?

    Someone sold me a bad IMEI AT&amp;T iphone 5. I had an AT&amp;T iphone 4 with straight talk prior to buying this phone. I didn't know the IMEI was bad so I bought the iphone 5 hoping to switch. I cut my SIM card and put it into the iphone 5. Everything worked perfectly fine so I went ahead and gave the dude the money. I went to sleep and wake up the next day and try to make a call and I get a message saying my phone has been blocked from the network. I contacted straight talk and they thought it was a problem of theirs so somehow they got my phone to work again. Everything was good , calls, texts , and data. 2 hours later, the same problem happens. So I call straight talk again , tell them the problem. They fix It again, 2 hours later , THE SAME PROBLEM. I gave up this time and began looking for answers. Is there any way I can use this iphone 5 with straight talk ? There was a comment I saw through my search for answers where if I get another straight talk sim everything would work again. Is this true? How can I use a bad IMEI AT&amp;T iphone 5 with straight talk ?

    If that IMEI has been blacklisted by AT&T, then it is blacklisted by all USA carriers, as well as several participating Canadian and Mexican carriers.
    As of 31 October 2012, USA Cellular Providers are sharing a common IMEI/ESN database to ensure that phones blacklisted on one carrier can't be activated on another carrier.  AT&T and T-Mobile are also participating members of the GSM-networks global shared blacklists.

Maybe you are looking for