WE IMPLEMENT THE ABSTRACT DAO CLASS TO HANDLE BASIC QUERIES
We create a new package com.xantrix.webapp.dao with a GenericRepository interface and two generics that both extend serialization. I represents the entities AND the primary key. Having done this we specify which are the basic methods of our persistence layer and which constitute the fundamental operations on the DBMS.
Now we create the class that implements this interface. We will call this class AbstractDao, which as the name implies is an abstract class.
THE ENTITY MANAGER
The first element we are going to insert is the EntityManager, thanks to this component we can perform all our queries. Provides a new notation @PeristentContext that creates a persistence context. After that we predict two variables, entityClass and the CriteriaBuilder. flush and clear consolidate data on our database. The code is explained in the source.
CRITERIA API CUSTOMER SELECTION FOR CODFID….
We create a new ClientiDao interface that will expose all the methods needed to manage the CLIENTI table.
We also create its implementation, ClientiDaoImpl. I will not go into further explanation because the code is explained in the source.
DOWNLOAD ARTICLE CODE
The AlphaShopV6.zip project is for the SQL Server DBMS while AlphaShopV7.zip is for MySQL. Below I have provided a video on how to import the project to Ubuntu 22.04 LTS.
Leave A Comment