[Solved] ADFBC validation when your data isn't normalized

Hello -
I'm working on a ADFBC/JSF app (using JDev 10.1.3.3) where I am developing a JSF page to edit data for a table whose data is denormalized. I'll explain using the EMPLOYEES table in the HR sample schema.
Change EMPLOYEES to...
a. Add a column (EMPLOYEES.DEPARTMENT_NAME) that holds the data in DEPARTMENTS.DEPARTMENT_NAME
b. Remove the foreign key EMP_DEPT_FK which links EMPLOYEES.DEPARTMENT_ID to DEPARTMENTS.DEPARTMENT_ID
The UI presents a field for EMPLOYEES.DEPARTMENT_ID. It also shows EMPLOYEES.DEPARTMENT_NAME as a read-only field.
When the user gives a value for EMPLOYEES.DEPARTMENT_ID, the app needs to
1. Validate the DEPARTMENT_ID using a function in a PL/SQL package
2. Populate the EMPLOYEES.DEPARTMENT_NAME field. Department name is retrieved using a function in a PL/SQL package that takes the department_id as a parameter.
3. Assign a NULL value to EMPLOYEES.DEPARTMENT_NAME if the provided DEPARTMENT_ID is NULL.
I don't have the option of changing the table structure.
I have an entity object for the EMPLOYEES records. To accomplish #1 I added a method validator on the DEPARTMENT_ID attribute to call the appropriate PL/SQL function using JDBC. My question is - where should #2 and #3 happen?
- In the same method validator on the attribute for DEPARTMENT_ID?
- In the setter for the DEPARTMENT_ID after the call to setAttributeInternal?
- Somewhere else?
Thanks for reading my question
-- Scott
Message was edited by:
scott.turnquist

Thanks Frank.
Here is what I came up with (in case anyone else has a similar question) - it works well so far.
In EmployeeEntityImpl:
    public boolean validateDepartmentId(Number data) {
        boolean valid = true;
        if (data != null ) {
            try {
                MyAppModuleImpl mod =
                    (MyAppModuleImpl )getDBTransaction().getRootApplicationModule();
                valid = mod.validateDepartmentId(data);  //method uses JDBC to call PL/SQL package function, could throw SQLException
            } catch (SQLException se) {
                log.error("Error while checking Department Id: " + data, se);
                valid = false;
        return valid;
    public void setDepartmentId(Number value) {
        setAttributeInternal(DEPARTMENTID, value);
        //Propogate changes to redundant DepartmentName field.
        //If we get this far, we will have passed the validation
        //called by setAttributeInternal()
        if (value == null) {
            if (getDepartmentName() != null) {
                setDepartmentName(null);
        } else {
            MyAppModuleImpl mod =
                (MyAppModuleImpl) getDBTransaction().getRootApplicationModule();
            try {
                String deptName = mod.lookupDepartmentNameFromDepartmentId(value);   //method uses JDBC to call PL/SQL package function, could throw SQLExeption
                if (deptName == null) {
                    log.error("Could not find department name for department id: " +
                              value);
                    throw new JboException("Invalid department id: " +
                                           value);
                } else {
                    setDepartmentName(deptName);
            } catch (SQLException se) {
                log.error("Could not validate department id: " + value, se);
                throw new JboException("Invalid department id: " + value);
    }

Similar Messages

  • Maintenance view event for validation when changing data

    Hi All,
    I have a maintenance view on a table that should validate some fields during user input.
    I am using event 05 'Creating a new entry' to validate fields when user creates new entry in the table. That works fine.
    I would like to have the same validations happening when the user changes fields of records already existing in the database. I tried to use event 01 'Before saving the data in the database' but the problem with this is that user can change many fields of many records before clicking 'Save'. I would like to have the error raised for incorrect entry already after the change.
    So far I could not find an event to do this but only by changing the code itself. The problem with that is whenever the code is regenerated the custom part is lost.
    Is there an event I can use that would help me achieve this?
    Thanks in advance.

    Hi Abhishek,
    I tried event 21, I`m playing around with that since that`s the only one triggered when I press Enter.
    The problem with this is that
    - the check runs when you press enter, so you can still change many fields of many records (one step maintenance) before the validation runs
    - you can`t raise an error message, because only the key fields will be input ready, the non-key fields will be readonly
    The way I currently handle is I undo the changes in 21 (get previous field values from TOTAL) and raise an information message i/o an error informing user to check the entry.
    What I`m looking for is an event that will raise a message and set focus on the incorrect field (if there`s one such).

  • The SQL statement is not valid - when importing data from SQL Server using a query

    Hi there,
    I am trying to import data from SQL to Power Pivot using a SQL query like below:
    SELECT Score.FieldCount, Score.Record.GetAt(0), Score.Record.GetAt(1),  Score.Record.GetAt(2),  Score.Record.GetAt(3),  Score.Record.GetAt(4)
    FROM 
    SELECT * FROM dbo.CLR1(
    dbo.CLR2('c:\FILES\Test.xml'), 
    'SELECT * FROM [dbo].[CXCustomer_Small]') Input
    ) Score
    And when I tried to validate it, it returns
    The SQL statement is not valid. A column name cannot be blank.
    I ran the above SQL statement in Management Studio and it works without problem. Any idea?
    Thanks!
    Chu
    -- Predict everything. http://www.predixionsoftware.com

    Never mind, I figured out - I need to give each column a name.
    -- Predict everything. http://www.predixionsoftware.com

  • How to solve : Conversion failed when converting date and/or time from character string

    hi there
    my query :
    cmd = new SqlCommand("SELECT RTRIM(invoiceNo) as [Order No.],RTRIM(InvoiceDate) as [Order Date],RTRIM(SubTotal) as [SubTotal],RTRIM(VATPer) as [Vat+ST %],RTRIM(VATAmount) as [VAT+ST Amount],RTRIM(DiscountPer) as [Discount %],RTRIM(DiscountAmount) as [Discount Amount],RTRIM(GrandTotal) as [Grand Total],RTRIM(TotalPayment) as [Total Payment],RTRIM(PaymentDue) as [Payment Due] from Invoice_Info where InvoiceDate between @d1 and @d2 order by InvoiceDate desc", con);
    cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "InvoiceDate").Value = dtpInvoiceDateFrom.Value.Date;
    cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "InvoiceDate").Value = dtpInvoiceDateTo.Value.Date;
    i use date timepicker / vs2010 / sql server 2008 r2 
    tnx

    i change the type of my column(InvoiceDate column) to isDate but it doesnt work and error again ....
    What exactly does this mean? What was the data type before the change? What is it now? Can you show us the CREATE TABLE statement for the table?
    i want send my source code /database for you and you chek it plz
    Generally, you should not expect people to solve problem over mail. You can upload code and database to Dropbox, Skydrive or similar service if you people to look at it.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • I restored my phone on iTunes, but when I did, all my info deleted and now it's my sister's old data. I tried to go back on iTunes and restore, but my original data isn't even an option. How do I get my old data back?

    I restored my phone on iTunes, but when I did, all my info deleted and now it's my sister's old data. I tried to go back on iTunes and restore, but my original data isn't even an option. How do I get my old data back?

    Before you did the resotore Via itunes you should of made a Back-up of your Data. But to be honest, i don't think that you would be able to get that stuff back.. Sorry mate

  • When installing new software, remember you MUST backup your data.

    This is from my own personal FAQ on my own website, but given the number of people who find themselves in a lurch with Snow Leopard, I had to post this again as a reminder for those not privy enough to find it by internet search engines, or look through this board.
    It is not a question of if data will be lost, but when. User error, data corruption, hardware failure, bugs in installers all play a part in potential disasters that only a backup can recover from. While you don't have the viruses or worms on the Mac like you do in the Windows world, it should be no excuse to not backup. These incidents can happen at anytime, and frequently without any warning.
    User error is the number one cause of lost data. You drag a file to the trash without meaning to, or use a keyboard shortcut used to send a file to the trash, or take a file out of its prescribed location, and the system gets broke. Before moving preinstalled folders or adding files to preinstalled folders, know what files belong where. Ask if you are unsure. And only start moving files once you know your critical files are backed up. In addition, if you lose track of files, and their location, having a backup you know where it exists will help you find those files which you lost. Manage your backups so that information isn't lost by accident.
    There are many disk utilities which claim to help keep your hard disk in good shape, and some are better than others, but if you don't have a backup, any of them could actually be worse than the backup software to your data as a simple power failure during use of one of those utilities can make the data get lost forever. Data corruption is probably the number two cause of losing data.
    Hardware failure. Eventually all hard disks, tape drives, CDs, DVDs, Zip drives, Zip disks, floppies, tapes, and even drive controllers fail. Hopefully most will not happen during the time between now and when you can afford your next computer, but it could happen. Getting an external source to backup your data to will lessen the risk of any one component making your data get lost forever. Whether it is an external hard drive, CD burner, tape drive, or a zip drive, the more backups of your data you have, the better off you'll be. Some will even say an off site backup is a good idea since a disaster could happen to your home or office that ruins the media on site.
    And then there are installers which without warning will remove different versions of programs, and in a few cases have been known to remove all the data on the system by accident.
    Always have at least two copies of your data at all times. As the loss of one data source due to any of the above failures means you will need the second backup to recover your data.
    And one copy should also be in a remote location in case something happens to the home location whether it is theft, accidental damage, or natural disaster.
    In the meantime if you aren't able to make the investment in backup software or hardware at least make yourself a hard copy of all your documents by printing them out. While not as easy to recover from as digital backups, at least you won't be trying to create the data from scratch.
    Apple includes Time Machine with Mac OS X 10.5 and 10.6.
    Apple includes a variety of methods of burning discs:
    http://support.apple.com/kb/index?page=search&src=support_site.results.disambigu ation&q=Burn%20a%20CD%20or%20DVD%20using%20Mac%20OS%20X
    Shirt-Pocket sells:
    http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html
    Apple also warns one in the documentation that comes in PDF on the installation DVD, but it does appear that some don't other to read this.
    Data recovery techniques exist, but none are 100% reliable, and some can cost thousand of U.S. dollars if you have failing hardware. So don't think for one moment backing up is optional. The day will come when you wish you had one.

    That you can always put on http://www.apple.com/feedback/
    or http://bugreporter.apple.com/
    I've asked for it there numerous times.

  • What does it mean when your ipod is in recovery mode and how do I solve this problem

    What does it mean when your ipod is in recovery mode and how do I solve this problem?

    Unless you have a backup from which you can restore, yes you will lose all of your data and settings.
    You should be able to sync your content back to the iPad if you have been syncing with iTunes all along. If you don't sync with iTunes, you can download much of your paid content again for free as long as you use the same Apple ID. This explains downloading past purchases.
    http://support.apple.com/kb/ht2519
    Unfortunately, at this point, you must restore the device before you can move on. There is nothing you can do to avoid it now.

  • I upgraded my iphone5 to ios7 when it got broken i backed up on iCloud before i got a new iPhone 5 now I want to restore the back up at the start up page and as iphone5 originally come with ios6 it is saying that my back up data isn't compatible

    i upgraded my iphone5 to ios7 when it got broken i backed up on iCloud before i got a new iPhone 5 now I want to restore the back up at the start up page and as iphone5 originally come with ios6 it is saying that my back up data isn't compatible

    thanks for your reply but if i upgrade the new phone to ios7 I will have to erase the Iphone to start again in other to get to the page where I have to chose restore from icloud, wont this process reverse the operating system back to ios6 or is that another way to restore other than erase and reinstall. pls help

  • Your account isn't valid to use in U.S store please change to saudi arabian store before purchasing

    Your account isn't valid to use in U.S store.you must switch to saudi arabian store before purchasing.
    i have changed the store to saudi Arabian store and it have been changed successfully.
    also, i sign out of apple store and resign again.
    but still i cannot update (what'app) becuase the same massage appears ( Your account isn't valid for use in U.S store.you must switch to saudi arabian store before purchasing.) i chose change store but  this massage appears( this page is temporarily unavailable).
    What is the soultion my problem ?

    Common problem, you will have to re-install the apps you downloaded in your previous store (country) in order to get updates.
    So, delete your WhatsApp by pressing the app icon for a few seconds and then click the cross.
    When done, go to the App Store and download WhatsApp again, now you can use WhatsApp and you will receive updates.

  • TS3297 My 2nd generation ipod touch is giving me the following error when I try accessing Itunes or the app store. "Cannot connect to the Store. A secure connection could not be established. Please check your date & time settings"  I am on a secure networ

    My 2nd generation ipod touch is giving me the following error when I try accessing Itunes or the app store. "Cannot connect to the Store. A secure connection could not be established. Please check your date & time settings"  I am on a secure networkl.

    Can't connect to the iTunes Store
    Make sure that time zone is correct in addition to date and time

  • I purchased an iPad mini on October 10th.  I want to return it and get the new ipad mini retina when it comes out.  How do I do that if the new ipad mini release date isn't until "later in November", which is beyond the 14 days from my purchase date?

    I purchased an iPad mini on October 10th.  I want to return it and get the new ipad mini retina when it comes out. I am currently still within the 14 day return/exchange window but how can I exchange it if the new ipad mini release date isn't until "later in November", which would be beyond the 14 days from my purchase date?  If apple announces a new version of a product you just purchased but won't actually release it for more than 14 days, how can you possibly exchange the one you just bought?  Is my only option to return the one I bought on the 10th (so return by 10/24) and then not have an iPad until the new one is available for purchase?  Or would it make any sense to return the one I bought, get a new one, which would presumably have another 14 day return window, and then exchange THAT one for the new ipad mini w/ retina when it comes out (hopefully within that second 14 day window)?

    Call the apple store you got it from and ask them. Sometimes in the past they've extended the 'no questions asked return' but only Apple can tell you for sure.

  • How can you manage data usage when cellular data is off, but you are using WiFi where your WiFi provider charges for data use?

    I spend quite a few months each year in Canada where I use a Telus Cellular Hub device which is also my WiFi Router.  My iPhone 5 has Cellular Data set to "Off" which insures I won't be charged via my Verizon Wireless Service Provider for charges while in Canada.  Trouble is Telus, Rogers and all the Canadian Internet Providers charge for all Data going through their Systems.  Again, My Cellular Data on the iPhone 5 is turned off, but I use WiFi for such things as checking the Weather, or FaceBook, or searching the Web. 
    I believe that things may be happening in the background from various Apps that use quite a lot of Data.  It could be that iCloud is part of the issue with things being backed up automatically.  It also could be that Apps like AP or other News Apps are sending large amounts of Data in the photos associated with their New Stories, etc.  I typically turn off the App Store "Updates" such that they don't automatically load.  The FaceBook works now posted videos play when you are just scrolling through the News Feed. 
    I have been trying to fine an article somewhere which focuses on this specific problem but unfortunately many if not most articles are about folks worried about using Cellular Data while in a WiFi environment when their Cellular Data is turned on. 
    Does anyone know of a fairly comprehensive article about what settings on which Apps might reduce the Data Usage when Cellular Data is turned "Off" but you are going through a Service Provider who charges for all Data Accessed even when you are using WiFi?

    Thanks for your comments, it is clear you understand my plight.  The trouble is fully understanding what Apps and App Features are transferring data in the background any time you happen to turn WiFi to on (even if you have had it off most of the day or night).  Obviously things like Location Services can constantly be sending and receiving data from my iPhone without any action on my part.  Also if you have things like photo backup on the iCloud then each time you take a photo you are sending a copy out.  All App Updates if set to Automatic also can add up to quite a bit of Data.  Reading the News on AP or scrolling through FB News Feed is actually adding up to a lot of Data.  There could be other culprits that I am not even thinking of.  I don't want to turn Apps like Find My Phone off or turn iCloud off due to loosing the value of such a program entirely.  Again thanks for your quick response. 

  • This isn't a question but rather a warning to anyone using the new OS for iphone 4.  The imessage uses up your data plan like crazy.  I called Apple about it and they said no it's not doing it.  I called AT

    The new OS is burning through my data plan like crazy and here's why.  Imessage uses your data plan and not your texting plan.  So every time you send a text message to someone with an iphone it uses imessage and it uses your data, not your text plan.  I couldn't figure out why I was burning through so much of my data plan so quickly.  I called Apple and they said, no it's not the data plan doing it.  I called AT&T and they said, yes, the imessage uses data instead of your texting plan if you are texting to another iphone.  Also, the new OS runs your apps all the time, even when you aren't using them.  So if you are not near wifi your apps are running and burning your data plan.  The AT&T guy took me through the steps to turn off the apps.  You can still use them but they won't be running constantly.  Seriously Apple, you should let people know this.  It does say it in the fine print on the website "data rates may apply" under imessage but most people will never read this.  So my data plan started on October 10th and it's already at 175 megabytes and I only have a 200 megabyte plan.  I've never used more than 50 to 75 megabytes in a month.  Apple get it together and be honest with people and tell them.  Quit denying the problem.  Most people have probably not even discovered this yet.  Wait till you get your bill.

    kimmie92592 wrote:
    It's not really common knowledge because I've talked to several people today and none of them knew about it.  Also, when I called Apple they said no the new OS is not using data.  Totally wrong answer.  You'd think they'd know about it and at least tell people.  The people who are going to be hit by this are people like me with the 200mb plans.  I just think it's best to spread the word so people can know what's happening.  I still don't know how I went through so much data in such a short period of time.  It's not happening anymore though, not since I fixed everything up last night. 
    If you are using a free wifi connection, there are no data charges with iMessage.  But in an area where you did NOT have a wifi connection, of course it used 3G and of course you got charged for it (or had it count against your plan limits).
    I'll ask again - without a wifi connection, just what did you think was happening?  How did you think your iPhone was able to magically send a message WITHOUT using any data connection?  A little bit of rational thought would have made you realize that there was no way, over a 3G connection (which is a service provided by your cellular service provider, NOT Apple), that you can send or receive ANYTHING without your service provider's plan picking it up.
    Nothing abut iMessage has ever hinted that it can, in any way, bypass your service provider when NOT using a wifi connection.

  • HT201210 I am unable to update my IPhone 4 to the IOS 6.  I managed to back up and transfer  and then when it asked to update I said yes and the sync process starte, left it overnight and it came up with an error if continue you will loose all your data. 

    I am unable to update my IPhone 4 to the IOS 6.  I managed to back up and transfer  and then when it asked to update I said yes and the sync process started, left it overnight and it came up with an error if continue you will loose all your data.  So stopped! Help!

    Are you currently on ios 4?  If so that's where the backup comes in.  You'll need to restore your backup once the software is updated.

  • What does that mean when your iPod only charges when you battery dies? (meaning: when my battery isn't dead it wont charge but when the battery is dead thats the only time it will charge)

    What does that mean when your iPod only charges when you battery dies? (meaning: when my battery isn't dead it wont charge but when the battery is dead thats the only time it will charge)

    - See:      
    iPod touch: Hardware troubleshooting
    - Try another cable. Some 5G iPods were shipped with Lightning cable that were either initially defective or failed after short use.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar      

Maybe you are looking for

  • Unable to close open and blocked web server ports

    I have been running the sun webserver 6.1 as a test development environment on my local pc (Windows 2000) at work. The machine crashed while the web server was running, and while the server instance stopped, the ports being used are still open and ap

  • Trying to create a template with adjustable text fields.

    I need to creat a form or template with adjustable text and image fields.  I need to have a background template for multiple pages that when I make a change to the template it make the changes to all pages, like the master page of indesign.  I also n

  • Can Anyone Help? Upgrade with Windows Issue

    I bought my daughter a Ipod nano for Christmas this past year (2005). Everything worked great until the new 6.0 upgrade. We downloaded the upgrade last week and it was completed successfully. Yet when I go to my desktop and try to go to the site I ge

  • Define Web Services in XI and call Web Services from XI

    Xi guys, I want to create some Web services in XI that will do the following things: receive an XML message over SOAP (from BEA WebLogic), execute 2-3 calls to an external HTTP Web Server from which I will get a response, export a file into another s

  • Sun Compiler Opengl

    Hi, Ive tried to install glut and opengl so the sun compiler can compile my opengl sources, however I cant seem to get it to work. Can I use the NVIDIA Opengl Headers and binaries or do I have to use Mesa / Sun GL? Can someone give me a step by step