    public void save(${entity-class} entity) {
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            currentSessionInContext.persist(entity);
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                org.hibernate.Transaction transaction = currentSessionInContext.beginTransaction();
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                currentSessionInContext.persist(entity);
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                transaction.commit();
            }
        }
    }

    public ${entity-class} update(${entity-class} entity) {
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            ${entity-class} managed = currentSessionInContext.merge(entity);
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
            return managed;
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                org.hibernate.Transaction transaction = currentSessionInContext.beginTransaction();
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                ${entity-class} managed = currentSessionInContext.merge(entity);
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                transaction.commit();
                return managed;
            }
        }
    }

    public void delete(${entity-class} entity) {
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            currentSessionInContext.remove(entity);
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                org.hibernate.Transaction transaction = currentSessionInContext.beginTransaction();
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                currentSessionInContext.remove(entity);
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                transaction.commit();
            }
        }
    }

    public void save(java.util.List<${entity-class}> entities) {
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            // for (int i = 0; i < entities.size(); i++) {
            //     currentSessionInContext.save(entities.get(i));
            //     if (i > 0 && i % 50 == 0) {
            //         currentSessionInContext.flush();
            //         currentSessionInContext.clear();
            //     }
            // }
            vn.io.lcx.common.task.batch.BatchHandler batchHandler = new vn.io.lcx.common.task.batch.BatchHandler();
            final org.hibernate.Session finalCurrentSessionInContext = currentSessionInContext;
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            batchHandler.processListInBatches(
                    entities,
                    splitEntities -> {
                        for (${entity-class} entity : splitEntities) {
                            try {
                                finalCurrentSessionInContext.persist(entity);
                            } catch (java.lang.Throwable t) {
                                finalCurrentSessionInContext.merge(entity);
                            }
                        }
                        finalCurrentSessionInContext.flush();
                        finalCurrentSessionInContext.clear();
                    },
                    50
            );
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                org.hibernate.Transaction transaction = currentSessionInContext.beginTransaction();
                // for (int i = 0; i < entities.size(); i++) {
                //     currentSessionInContext.save(entities.get(i));
                //     if (i > 0 && i % 50 == 0) {
                //         currentSessionInContext.flush();
                //         currentSessionInContext.clear();
                //     }
                // }
                vn.io.lcx.common.task.batch.BatchHandler batchHandler = new vn.io.lcx.common.task.batch.BatchHandler();
                final org.hibernate.Session finalCurrentSessionInContext = currentSessionInContext;
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                batchHandler.processListInBatches(
                        entities,
                        splitEntities -> {
                            for (${entity-class} entity : splitEntities) {
                                try {
                                    finalCurrentSessionInContext.persist(entity);
                                } catch (java.lang.Throwable t) {
                                    finalCurrentSessionInContext.merge(entity);
                                }
                            }
                            finalCurrentSessionInContext.flush();
                            finalCurrentSessionInContext.clear();
                        },
                        50
                );
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                transaction.commit();
            }
        }
    }

    public void update(java.util.List<${entity-class}> entities) {
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            // for (int i = 0; i < entities.size(); i++) {
            //     currentSessionInContext.merge(entities.get(i));
            //     if (i > 0 && i % 50 == 0) {
            //         currentSessionInContext.flush();
            //         currentSessionInContext.clear();
            //     }
            // }
            vn.io.lcx.common.task.batch.BatchHandler batchHandler = new vn.io.lcx.common.task.batch.BatchHandler();
            final org.hibernate.Session finalCurrentSessionInContext = currentSessionInContext;
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            batchHandler.processListInBatches(
                    entities,
                    splitEntities -> {
                        for (${entity-class} entity : splitEntities) {
                            finalCurrentSessionInContext.merge(entity);
                        }
                        finalCurrentSessionInContext.flush();
                        finalCurrentSessionInContext.clear();
                    },
                    50
            );
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                org.hibernate.Transaction transaction = currentSessionInContext.beginTransaction();
                // for (int i = 0; i < entities.size(); i++) {
                //     currentSessionInContext.merge(entities.get(i));
                //     if (i > 0 && i % 50 == 0) {
                //         currentSessionInContext.flush();
                //         currentSessionInContext.clear();
                //     }
                // }
                vn.io.lcx.common.task.batch.BatchHandler batchHandler = new vn.io.lcx.common.task.batch.BatchHandler();
                final org.hibernate.Session finalCurrentSessionInContext = currentSessionInContext;
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                batchHandler.processListInBatches(
                        entities,
                        splitEntities -> {
                            for (${entity-class} entity : splitEntities) {
                                finalCurrentSessionInContext.merge(entity);
                            }
                            finalCurrentSessionInContext.flush();
                            finalCurrentSessionInContext.clear();
                        },
                        50
                );
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                transaction.commit();
            }
        }
    }

    public void delete(java.util.List<${entity-class}> entities) {
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            // for (int i = 0; i < entities.size(); i++) {
            //     currentSessionInContext.remove(entities.get(i));
            //     if (i > 0 && i % 50 == 0) {
            //         currentSessionInContext.flush();
            //         currentSessionInContext.clear();
            //     }
            // }
            vn.io.lcx.common.task.batch.BatchHandler batchHandler = new vn.io.lcx.common.task.batch.BatchHandler();
            final org.hibernate.Session finalCurrentSessionInContext = currentSessionInContext;
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            batchHandler.processListInBatches(
                    entities,
                    splitEntities -> {
                        for (${entity-class} entity : splitEntities) {
                            finalCurrentSessionInContext.remove(entity);
                        }
                        finalCurrentSessionInContext.flush();
                        finalCurrentSessionInContext.clear();
                    },
                    50
            );
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                org.hibernate.Transaction transaction = currentSessionInContext.beginTransaction();
                // for (int i = 0; i < entities.size(); i++) {
                //     currentSessionInContext.remove(entities.get(i));
                //     if (i > 0 && i % 50 == 0) {
                //         currentSessionInContext.flush();
                //         currentSessionInContext.clear();
                //     }
                // }
                vn.io.lcx.common.task.batch.BatchHandler batchHandler = new vn.io.lcx.common.task.batch.BatchHandler();
                final org.hibernate.Session finalCurrentSessionInContext = currentSessionInContext;
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                batchHandler.processListInBatches(
                        entities,
                        splitEntities -> {
                            for (${entity-class} entity : splitEntities) {
                                finalCurrentSessionInContext.remove(entity);
                            }
                            finalCurrentSessionInContext.flush();
                            finalCurrentSessionInContext.clear();
                        },
                        50
                );
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                transaction.commit();
            }
        }
    }

    public java.util.List<${entity-class}> find(vn.io.lcx.jpa.respository.CriteriaHandler<${entity-class}> handler) {
        java.util.List<${entity-class}> result = new java.util.ArrayList<>();
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            final jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder = currentSessionInContext.getCriteriaBuilder();
            final jakarta.persistence.criteria.CriteriaQuery<${entity-class}> criteriaQuery = criteriaBuilder.createQuery(${entity-class}.class);
            jakarta.persistence.criteria.Root<${entity-class}> root = criteriaQuery.from(${entity-class}.class);
            criteriaQuery.select(root);
            jakarta.persistence.criteria.Predicate predicate = null;
            if (handler != null) {
                predicate = handler.toPredicate(criteriaBuilder, criteriaQuery, root);
                criteriaQuery.where(predicate);
            }
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            org.hibernate.query.Query<${entity-class}> query = currentSessionInContext.createQuery(criteriaQuery);
            result.addAll(query.getResultList());
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                final jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder = currentSessionInContext.getCriteriaBuilder();
                final jakarta.persistence.criteria.CriteriaQuery<${entity-class}> criteriaQuery = criteriaBuilder.createQuery(${entity-class}.class);
                jakarta.persistence.criteria.Root<${entity-class}> root = criteriaQuery.from(${entity-class}.class);
                criteriaQuery.select(root);
                jakarta.persistence.criteria.Predicate predicate = null;
                if (handler != null) {
                    predicate = handler.toPredicate(criteriaBuilder, criteriaQuery, root);
                    criteriaQuery.where(predicate);
                }
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                org.hibernate.query.Query<${entity-class}> query = currentSessionInContext.createQuery(criteriaQuery);
                result.addAll(query.getResultList());
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
            }
        }
        return result;
    }

    public java.util.Optional<${entity-class}> findOne(vn.io.lcx.jpa.respository.CriteriaHandler<${entity-class}> handler) {
        java.util.Optional<${entity-class}> result = java.util.Optional.empty();
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            final jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder = currentSessionInContext.getCriteriaBuilder();
            final jakarta.persistence.criteria.CriteriaQuery<${entity-class}> criteriaQuery = criteriaBuilder.createQuery(${entity-class}.class);
            jakarta.persistence.criteria.Root<${entity-class}> root = criteriaQuery.from(${entity-class}.class);
            criteriaQuery.select(root);
            jakarta.persistence.criteria.Predicate predicate = null;
            if (handler != null) {
                predicate = handler.toPredicate(criteriaBuilder, criteriaQuery, root);
                criteriaQuery.where(predicate);
            }
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            org.hibernate.query.Query<${entity-class}> query = currentSessionInContext.createQuery(criteriaQuery);
            result = java.util.Optional.ofNullable(query.uniqueResult());
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                final jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder = currentSessionInContext.getCriteriaBuilder();
                final jakarta.persistence.criteria.CriteriaQuery<${entity-class}> criteriaQuery = criteriaBuilder.createQuery(${entity-class}.class);
                jakarta.persistence.criteria.Root<${entity-class}> root = criteriaQuery.from(${entity-class}.class);
                criteriaQuery.select(root);
                jakarta.persistence.criteria.Predicate predicate = null;
                if (handler != null) {
                    predicate = handler.toPredicate(criteriaBuilder, criteriaQuery, root);
                    criteriaQuery.where(predicate);
                }
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                org.hibernate.query.Query<${entity-class}> query = currentSessionInContext.createQuery(criteriaQuery);
                result = java.util.Optional.ofNullable(query.uniqueResult());
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
            }
        }
        return result;
    }

    public vn.io.lcx.common.database.pageable.Page<${entity-class}> find(vn.io.lcx.jpa.respository.CriteriaHandler<${entity-class}> handler, vn.io.lcx.common.database.pageable.Pageable pageable) {
        java.util.concurrent.atomic.AtomicReference<vn.io.lcx.common.database.pageable.Page<${entity-class}>> result = new java.util.concurrent.atomic.AtomicReference<>();
        final org.hibernate.SessionFactory sessionFactory = vn.io.lcx.jpa.context.EntityContainer.getEntityManager(${entity-class}.class);
        // This variable is the result of checking whether the method
        // in the class annotated with `@vn.io.lcx.jpa.annotation.Service`
        // is also annotated with `@vn.io.lcx.jpa.annotation.Transactional`.
        // This check occurs in the Proxy layer of the class annotated with `@vn.io.lcx.jpa.annotation.Service`.
        boolean transactionOpen = vn.io.lcx.jpa.context.JpaContext.isTransactionOpen();
        if (transactionOpen) {
            boolean sessionIsJustCreate = false;
            org.hibernate.Session currentSessionInContext = vn.io.lcx.jpa.context.JpaContext.getSession(${entity-class}.class);
            if (currentSessionInContext == null) {
                currentSessionInContext = sessionFactory.openSession();
                currentSessionInContext.doWork(connection -> connection.setTransactionIsolation(vn.io.lcx.jpa.context.JpaContext.getTransactionIsolation()));
                sessionIsJustCreate = true;
            }
            int transactionMode = vn.io.lcx.jpa.context.JpaContext.getTransactionMode();
            org.hibernate.Transaction transaction = vn.io.lcx.jpa.context.JpaContext.getTransaction(${entity-class}.class);
            switch (transactionMode) {
                case vn.io.lcx.jpa.context.JpaConstant.CREATE_NEW_TRANSACTION_MODE:
                    if (sessionIsJustCreate) {
                        transaction = currentSessionInContext.beginTransaction();
                    } else {
                        if (transaction != null) {
                            transaction.commit();
                        }
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                case vn.io.lcx.jpa.context.JpaConstant.USE_EXISTING_TRANSACTION_MODE:
                    if (transaction == null) {
                        transaction = currentSessionInContext.beginTransaction();
                    }
                    break;
                default:
                    throw new vn.io.lcx.jpa.exception.JpaException("Invalid transaction mode");
            }
            vn.io.lcx.jpa.context.JpaContext.setSession(${entity-class}.class, currentSessionInContext);
            vn.io.lcx.jpa.context.JpaContext.setTransaction(${entity-class}.class, transaction);
            vn.io.lcx.common.database.pageable.PageableImpl pageimpl = (vn.io.lcx.common.database.pageable.PageableImpl) pageable;
            final jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder = currentSessionInContext.getCriteriaBuilder();
            final jakarta.persistence.criteria.CriteriaQuery<${entity-class}> criteriaQuery = criteriaBuilder.createQuery(${entity-class}.class);
            jakarta.persistence.criteria.Root<${entity-class}> root = criteriaQuery.from(${entity-class}.class);
            java.util.List<jakarta.persistence.criteria.Order> orders = new java.util.ArrayList<>();
            pageimpl.getFieldNameAndDirectionMap().forEach((field, direction) -> {
                if (vn.io.lcx.common.database.pageable.Direction.DESC.equals(direction)) {
                    orders.add(criteriaBuilder.desc(root.get(field)));
                } else {
                    orders.add(criteriaBuilder.asc(root.get(field)));
                }
            });
            criteriaQuery.select(root).orderBy(orders);
            jakarta.persistence.criteria.Predicate predicate = null;
            if (handler != null) {
                predicate = handler.toPredicate(criteriaBuilder, criteriaQuery, root);
                criteriaQuery.where(predicate);
            }
            final double startingTime = (double) java.lang.System.currentTimeMillis();
            org.hibernate.query.Query<${entity-class}> query = currentSessionInContext.createQuery(criteriaQuery);
            query.setFirstResult(pageimpl.getOffset());
            query.setMaxResults(pageimpl.getPageSize());
            java.util.List<${entity-class}> queryResult = query.getResultList();

            final jakarta.persistence.criteria.CriteriaQuery<Long> countQuery = criteriaBuilder.createQuery(Long.class);
            jakarta.persistence.criteria.Root<${entity-class}> countRoot = countQuery.from(${entity-class}.class);
            if (handler != null) {
                jakarta.persistence.criteria.Predicate countPredicate = handler.toPredicate(criteriaBuilder, countQuery, countRoot);
                countQuery.select(criteriaBuilder.count(countRoot))
                        .where(countPredicate);
            }
            Long totalItems = currentSessionInContext.createQuery(countQuery).getSingleResult();
            final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
            vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
            result.set(
                    vn.io.lcx.common.database.pageable.Page.<${entity-class}>create(
                            queryResult,
                            totalItems,
                            pageimpl.getPageNumber(),
                            pageimpl.getPageSize()
                    )
            );
        } else {
            try (org.hibernate.Session currentSessionInContext = sessionFactory.openSession()) {
                vn.io.lcx.common.database.pageable.PageableImpl pageimpl = (vn.io.lcx.common.database.pageable.PageableImpl) pageable;
                final jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder = currentSessionInContext.getCriteriaBuilder();
                final jakarta.persistence.criteria.CriteriaQuery<${entity-class}> criteriaQuery = criteriaBuilder.createQuery(${entity-class}.class);
                jakarta.persistence.criteria.Root<${entity-class}> root = criteriaQuery.from(${entity-class}.class);
                java.util.List<jakarta.persistence.criteria.Order> orders = new java.util.ArrayList<>();
                pageimpl.getFieldNameAndDirectionMap().forEach((field, direction) -> {
                    if (vn.io.lcx.common.database.pageable.Direction.DESC.equals(direction)) {
                        orders.add(criteriaBuilder.desc(root.get(field)));
                    } else {
                        orders.add(criteriaBuilder.asc(root.get(field)));
                    }
                });
                criteriaQuery.select(root).orderBy(orders);
                jakarta.persistence.criteria.Predicate predicate = null;
                if (handler != null) {
                    predicate = handler.toPredicate(criteriaBuilder, criteriaQuery, root);
                    criteriaQuery.where(predicate);
                }
                final double startingTime = (double) java.lang.System.currentTimeMillis();
                org.hibernate.query.Query<${entity-class}> query = currentSessionInContext.createQuery(criteriaQuery);
                query.setFirstResult(pageimpl.getOffset());
                query.setMaxResults(pageimpl.getPageSize());
                java.util.List<${entity-class}> queryResult = query.getResultList();

                final jakarta.persistence.criteria.CriteriaQuery<Long> countQuery = criteriaBuilder.createQuery(Long.class);
                jakarta.persistence.criteria.Root<${entity-class}> countRoot = countQuery.from(${entity-class}.class);
                if (handler != null) {
                    jakarta.persistence.criteria.Predicate countPredicate = handler.toPredicate(criteriaBuilder, countQuery, countRoot);
                    countQuery.select(criteriaBuilder.count(countRoot))
                            .where(countPredicate);
                }
                Long totalItems = currentSessionInContext.createQuery(countQuery).getSingleResult();
                final double duration = ((double) java.lang.System.currentTimeMillis()) - startingTime;
                vn.io.lcx.common.utils.LogUtils.writeLog(this.getClass(), vn.io.lcx.common.utils.LogUtils.Level.INFO, "Executed SQL in {} ms", duration);
                result.set(
                        vn.io.lcx.common.database.pageable.Page.<${entity-class}>create(
                                queryResult,
                                totalItems,
                                pageimpl.getPageNumber(),
                                pageimpl.getPageSize()
                        )
                );
            }
        }
        return result.get();
    }
