2 Replies Latest reply: May 12, 2011 9:53 AM by Dimitar Dimitrov RSS

    Persisting Entity Values mapped to a View

    854804
      Hi,

      I have an entity mapped to a database view. A collection of such entities is rendered in a table with 2 columns beeing editable. Further, I have a button for saving changes made to the cells in these 2 columns.

      My question is, how can I persist changes? How does ADF knows which rows have been changed? It is not possible to write in a daabase view.

      Thanks in advance!
        • 1. Re: Persisting Entity Values mapped to a View
          Sascha Herrmann
          Assuming you're using an Oracle database:

          That depends on whether the view's columns are updateable or not.
          If they're updateable, then the database knows how to handle the update on the view, and there is nothing that you need to do additionally.
          If not, then you need to create an "instead-of" trigger in the database that takes care of updating the tables instead of the view.

          More information here:
          http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5226026422731

          Sascha
          • 2. Re: Persisting Entity Values mapped to a View
            Dimitar Dimitrov
            How does ADF knows which rows have been changed?
            ADF internally keeps track of all the new or modified Entity instances. There is a way to get the list, but this is neither recommended nor necessary.
            It is not possible to write in a database view?
            Follow Sasha's suggestions. I would add the following - if you have a non-updateble DB view but you do not want to use instead-of triggers in DB, you can override the method <tt>EntityImpl.doDML(...)</tt> which is invoked by the framework in order to persist changes. This method is documented very well, have a look at its Javadoc.

            Dimitar