[[mapping-to-a-view]]
= Mapping to a View

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


JDO/DataNucleus supports the ability to map the entity that is mapped to a view rather than a database table.
Moreover, DataNucleus itself can create/maintain this view.

One use case for this is to support use cases which act upon aggregate information.
An link:https://github.com/estatio/estatio/blob/b77d0b03ec86463227ba90f8341299066ddba69f/estatioapp/module/lease/dom/src/main/java/org/estatio/dom/lease/invoicing/viewmodel/InvoiceSummaryForPropertyDueDateStatus.java#L57[example] is in the (non-ASF) http://github.com/estatio/estatio[Estatio] application, which uses a view to define an "invoice run": a representatoin of all pending invoices to be sent out for a particular shopping centre.
(Note that example also shows the entity as being "non-durable", but if the view is read/write then -- I think -- that this isn't necessary required).


For more on this topic, see the link:http://www.datanucleus.org/products/datanucleus/jdo/mapping.html#schema_rdbms_views[DataNucleus documentation].


