Skip to content

chore: Migrate CaseManagementCPPDAOImpl from HibernateDaoSupport to SessionFactory#1621

Open
Copilot wants to merge 4 commits intomaintenancefrom
copilot/choremigrate-casemanagementcppdao
Open

chore: Migrate CaseManagementCPPDAOImpl from HibernateDaoSupport to SessionFactory#1621
Copilot wants to merge 4 commits intomaintenancefrom
copilot/choremigrate-casemanagementcppdao

Conversation

Copy link

Copilot AI commented Jan 15, 2026

Migrates CaseManagementCPPDAOImpl from deprecated HibernateDaoSupport to direct SessionFactory injection for Spring 6 compatibility.

Changes

  • Class declaration: Removed HibernateDaoSupport inheritance, added @Autowired SessionFactory field with getSession() helper
  • Query API: Replaced getHibernateTemplate().find() with typed createQuery() using named parameters
  • Persistence API: Replaced getHibernateTemplate().saveOrUpdate() with getSession().saveOrUpdate()
  • Documentation: Added class and method-level JavaDoc

Before:

public class CaseManagementCPPDAOImpl extends HibernateDaoSupport implements CaseManagementCPPDAO {
    public CaseManagementCPP getCPP(String demographic_no) {
        List results = this.getHibernateTemplate().find(
            "from CaseManagementCPP cpp where cpp.demographic_no = ?0 order by update_date desc",
            new Object[]{demographic_no});
        return (results.size() != 0) ? (CaseManagementCPP) results.get(0) : null;
    }
}

After:

public class CaseManagementCPPDAOImpl implements CaseManagementCPPDAO {
    @Autowired
    private SessionFactory sessionFactory;
    
    protected Session getSession() {
        return sessionFactory.getCurrentSession();
    }
    
    public CaseManagementCPP getCPP(String demographic_no) {
        List<CaseManagementCPP> results = getSession()
            .createQuery("from CaseManagementCPP cpp where cpp.demographic_no = :demographicNo order by update_date desc", CaseManagementCPP.class)
            .setParameter("demographicNo", demographic_no)
            .list();
        return !results.isEmpty() ? results.get(0) : null;
    }
}

Part of Epic #1110 - Spring 6 / Jakarta EE migration preparation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • jaspersoft.jfrog.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Open-O/Open-O org.codehaus.plexus.classworlds.launcher.Launcher clean compile -DskipTests -q (dns block)
  • jitpack.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Open-O/Open-O org.codehaus.plexus.classworlds.launcher.Launcher clean compile -DskipTests -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>chore: Migrate CaseManagementCPPDAOImpl from HibernateDaoSupport to SessionFactory</issue_title>
<issue_description>## Summary
Migrate CaseManagementCPPDAOImpl from deprecated HibernateDaoSupport to direct SessionFactory injection as preparation for Jakarta EE migration.

Why

HibernateDaoSupport and HibernateTemplate are removed in Spring 6. This migration allows testing on Spring 5.3 while preparing for Jakarta.

File

src/main/java/ca/openosp/openo/casemgmt/dao/CaseManagementCPPDAOImpl.java

Difficulty

MEDIUM

Workflow

  1. Branch from develop: git checkout develop && git pull && git checkout -b chore/migrate-casemanagementcppdao
  2. Make changes (see Migration Steps below)
  3. Run tests: make install --run-tests
  4. Create PR targeting develop branch

Migration Steps

Step 1: Update Class Declaration

// BEFORE
public class CaseManagementCPPDAOImpl extends HibernateDaoSupport implements CaseManagementCPPDAO {
    @Autowired
    public void setSessionFactoryOverride(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }
}

// AFTER
public class CaseManagementCPPDAOImpl implements CaseManagementCPPDAO {
    @Autowired
    private SessionFactory sessionFactory;

    protected Session getSession() {
        return sessionFactory.getCurrentSession();
    }
}

Step 2: Update Imports

// REMOVE:
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.orm.hibernate5.HibernateTemplate;

// ADD:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

Step 3: Replace getHibernateTemplate() Calls

Before After
getHibernateTemplate().find(hql, args) getSession().createQuery(hql).setParameter(0, arg).list()
getHibernateTemplate().get(Class, id) getSession().get(Class, id)
getHibernateTemplate().save(e) getSession().save(e)
getHibernateTemplate().saveOrUpdate(e) getSession().saveOrUpdate(e)
getHibernateTemplate().update(e) getSession().update(e)
getHibernateTemplate().delete(e) getSession().delete(e)
getHibernateTemplate().flush() getSession().flush()

Step 4: Run Tests

make install --run-tests

Step 5: Add JavaDoc

Add class-level and method-level JavaDoc documentation before creating PR.

Testing

  • CPP (Cumulative Patient Profile) workflows

Acceptance Criteria

  • No HibernateDaoSupport or HibernateTemplate imports remain
  • All tests pass
  • Related functionality verified in UI
  • Class has comprehensive JavaDoc (purpose, usage, @SInCE)
  • All public methods have JavaDoc (@param, @return, @throws)
  • Complex logic has inline comments

Parent Epic

Part of Epic #1110</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 15, 2026 01:52
…actory

Co-authored-by: yingbull <8680161+yingbull@users.noreply.github.com>
Co-authored-by: yingbull <8680161+yingbull@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate CaseManagementCPPDAOImpl to use SessionFactory chore: Migrate CaseManagementCPPDAOImpl from HibernateDaoSupport to SessionFactory Jan 15, 2026
Copilot AI requested a review from yingbull January 15, 2026 01:55
@keploy
Copy link

keploy bot commented Jan 15, 2026

To generate Unit Tests for this PR, please click here.

@yingbull yingbull marked this pull request as ready for review January 15, 2026 23:53
Copilot AI review requested due to automatic review settings January 15, 2026 23:53
@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates CaseManagementCPPDAOImpl from the deprecated HibernateDaoSupport to direct SessionFactory injection, preparing the codebase for Spring 6 compatibility as part of Epic #1110 (Jakarta EE Migration Preparation).

Changes:

  • Removed HibernateDaoSupport inheritance and replaced with @Autowired SessionFactory field injection
  • Migrated from HibernateTemplate API to direct Hibernate Session API with typed queries
  • Updated query syntax from positional parameters (?0) to named parameters (:demographicNo)
  • Added comprehensive JavaDoc documentation for the class and all methods

@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 01c15fc.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@yingbull
Copy link

yingbull commented Feb 1, 2026

Unable to reassign; closing. Can be reopened by openosp. @kk-chung

@yingbull
Copy link

yingbull commented Feb 1, 2026

Unable to reassign; requesting close. Can be reopened by openosp. @kk-chung

@sebastian-j-ibanez sebastian-j-ibanez changed the base branch from develop to maintenance March 13, 2026 17:38
@sebastian-j-ibanez
Copy link
Collaborator

Retargeting from develop -> maintenance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: maintenance Code refactoring, dependency updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: Migrate CaseManagementCPPDAOImpl from HibernateDaoSupport to SessionFactory

4 participants