In the development process the standard
way is to use Model View Controller architecture, where the separation of each
component comes into play.
1.
Model – Model represents the data &
rules that govern access & update of data. That means basically it will
contain database objects to be accessed.
2.
View – View is the web pages that we can
display. The HTML, JSP pages are under the View category.
3.
Controller – This is the controlling
mechanism between model & view. This will communicate with Model & View
& translate & transport data objects.
Figure MVC Architecture of JPA
1.
DAO – DAO means Data Access Objects
& it provides an abstract interface to the databases. Basically in DAO
layer we write queries to access the database. We can write DAO’s & include
methods as much as we wanted. When writing DAO we can use OpenJPA NamedQueries
directly.
2.
Domain – Domain means the entity classes
for the tables in the database. For each table in the database, we can create a
mapping entity class & define the table entities as objects. It is much
more efficient way than traditional relational database mapping. Domain also
called as POJO (Plain Old Java Objects).
In order to create the connection between database & domains, need
to create an xml file including such details. That xml file is named as “persistance.xml”
by default. It is similar to the normal database connection establishment, but it is defined in xml format. A typical persistance.xml
file would contain following details.
This holds the connection details &
there are two ways to retrieve the data objects. One method is using Entity
manager & other way is using Session factory. I used entity manager factory
in the DAO layers.
Hope this post would help you to understand the MVC architecture of the OpenJPA. Stay in touch :)
uc satın al
ReplyDeleteözel ambulans
nft nasıl alınır
yurtdışı kargo
en son çıkan perde modelleri
minecraft premium
en son çıkan perde modelleri
lisans satın al