While creating real-time projects, implementing data access
layer of an enterprise application is a challenging task.
Data persistence means storing, retrieving of data and also
making modification to the data permanently.
In java projects data can be stored in
Variables
File
Database
Variables can store the data temporarily.
To make the data as persistence, it must be stored in File
or database.
Data persistence contains 3 components
Data
Medium
Storage
When storage is a file(flat file) then we use IO Streams to
store and read the raw data from the files and we use serialization
and deserialization to store and read objects from file.
When storage is a database then, we use JDBC API to store or
read the data from database.
If data is in a Java object then we can use either Jdbc or
ORM tool to store and read the object from database.
Using JDBC API in a Java application, to perform CRUD operations on the data of Java Objects has some issues.
JDBC API can only transfer raw data, but not objects. So, the application has to convert the object into RAW data.
If any changes are made to the DB schema then the queries defined at various places of the application are need to
be modified and it will take more time.
The exceptions of JDBC API are checked exceptions so, where ever JDBC code is defined in application, we need
to keep the code under try & catch block.
As a solution, third parties started providing ORM tools or ORM frameworks.
ORM tools/frameworks transfers objects between an application and database, by using the low level JDBC API
internally</>
No comments:
Post a Comment