Skip to content

server: Merge each DAO interface into its Hibernate implementation - #1025

Merged
fushar merged 1 commit into
masterfrom
merge-dao-hibernate
Oct 3, 2026
Merged

fushar merged 1 commit into
masterfrom
merge-dao-hibernate

Conversation

@fushar

@fushar fushar commented Oct 3, 2026

Copy link
Copy Markdown
Member

Every DAO was split into an interface in judgels.persistence.dao and its only implementation in judgels.persistence.hibernate.dao, bound together one by one in JudgelsServerHibernateDaoModule. The split hid nothing, because the interfaces already expose JPA criteria through CriteriaPredicate, and it doubled the files to read and maintain.

Each DAO is now a single class under the interface's old name, so callers are unchanged, and the judgels.persistence.hibernate package is folded into judgels.persistence.

  • DAOs: each XHibernateDao moves to judgels.persistence.dao.XDao, replacing the interface of the same name. Nested query builders such as ContestDao.ContestQueryBuilder become public static classes.
  • Base types: Dao, JudgelsDao, UnmodifiableDao and QueryBuilder are now the classes formerly prefixed with Hibernate. HibernateDaoData is renamed to DaoData.
  • Generic submission DAOs: the three Abstract…HibernateDao classes take over the BaseProgrammingSubmissionDao, BaseProgrammingGradingDao and BaseBundleItemSubmissionDao names, and declare as abstract the factory methods their subclasses supply.
  • Wiring: JudgelsServerHibernateDaoModule is deleted. Dagger builds each DAO from its @Inject constructor.
  • ContestRoleDao: its interface exposed only the four role checks, while its implementation extended JudgelsHibernateDao<ContestModel>. To keep the contest CRUD methods out of reach, it now holds a ContestDao instead of extending JudgelsDao. It was the only DAO whose interface was narrower than its implementation.
  • Tests: the persistence integration tests move to judgels.persistence as DaoIntegrationTests and JudgelsDaoIntegrationTests.

Trade-off: a unit test can no longer fake a DAO by implementing an interface; it has to mock the class. Only ContestWebConfigFetcherTests mocks DAOs today.

Every DAO was split into an interface in judgels.persistence.dao and its only implementation in judgels.persistence.hibernate.dao, bound together one by one in JudgelsServerHibernateDaoModule. The split hid nothing, because the interfaces already expose JPA criteria through CriteriaPredicate, and it doubled the files to read and maintain.

Each DAO is now a single class under the interface's old name, so callers are unchanged, and Dagger builds it from its @Inject constructor. The judgels.persistence.hibernate package is folded into judgels.persistence.
@fushar
fushar merged commit 5296288 into master Oct 3, 2026
4 checks passed
@fushar
fushar deleted the merge-dao-hibernate branch October 3, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant