Repository navigation
server: Merge each DAO interface into its Hibernate implementation - #1025
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every DAO was split into an interface in
judgels.persistence.daoand its only implementation injudgels.persistence.hibernate.dao, bound together one by one inJudgelsServerHibernateDaoModule. The split hid nothing, because the interfaces already expose JPA criteria throughCriteriaPredicate, 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.hibernatepackage is folded intojudgels.persistence.XHibernateDaomoves tojudgels.persistence.dao.XDao, replacing the interface of the same name. Nested query builders such asContestDao.ContestQueryBuilderbecome public static classes.Dao,JudgelsDao,UnmodifiableDaoandQueryBuilderare now the classes formerly prefixed withHibernate.HibernateDaoDatais renamed toDaoData.Abstract…HibernateDaoclasses take over theBaseProgrammingSubmissionDao,BaseProgrammingGradingDaoandBaseBundleItemSubmissionDaonames, and declare as abstract the factory methods their subclasses supply.JudgelsServerHibernateDaoModuleis deleted. Dagger builds each DAO from its@Injectconstructor.ContestRoleDao: its interface exposed only the four role checks, while its implementation extendedJudgelsHibernateDao<ContestModel>. To keep the contest CRUD methods out of reach, it now holds aContestDaoinstead of extendingJudgelsDao. It was the only DAO whose interface was narrower than its implementation.judgels.persistenceasDaoIntegrationTestsandJudgelsDaoIntegrationTests.Trade-off: a unit test can no longer fake a DAO by implementing an interface; it has to mock the class. Only
ContestWebConfigFetcherTestsmocks DAOs today.