@Test public void testFindUpgrade() throws Exception { List<UpgradeEntity> items = dao.findUpgrades(clusterId.longValue()); assertTrue(items.size() > 0); UpgradeEntity entity = dao.findUpgrade(items.get(0).getId().longValue()); assertNotNull(entity); assertEquals(1, entity.getUpgradeGroups().size()); UpgradeGroupEntity group = dao.findUpgradeGroup( entity.getUpgradeGroups().get(0).getId().longValue()); assertNotNull(group); Assert.assertNotSame(entity.getUpgradeGroups().get(0), group); assertEquals("group_name", group.getName()); assertEquals("group title", group.getTitle()); }
@RequiresSession public UpgradeEntity findUpgrade(long upgradeId) { TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery( "UpgradeEntity.findUpgrade", UpgradeEntity.class); query.setParameter("upgradeId", Long.valueOf(upgradeId)); return daoUtils.selectSingle(query); }
UpgradeDAO { @RequiresSession public UpgradeEntity findUpgrade(long upgradeId) { TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery( "UpgradeEntity.findUpgrade", UpgradeEntity.class); query.setParameter("upgradeId", Long.valueOf(upgradeId)); return daoUtils.selectSingle(query); } }
UpgradeDAO { @RequiresSession public UpgradeEntity findUpgrade(long upgradeId) { TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery( "UpgradeEntity.findUpgrade", UpgradeEntity.class); query.setParameter("upgradeId", Long.valueOf(upgradeId)); return daoUtils.selectSingle(query); }  }
UpgradeDAO { @RequiresSession public UpgradeEntity findUpgrade(long upgradeId) { TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery( "UpgradeEntity.findUpgrade", UpgradeEntity.class); query.setParameter("upgradeId", Long.valueOf(upgradeId)); return daoUtils.selectSingle(query); }  @RequiresSession List<UpgradeEntity> findAll(); @RequiresSession List<UpgradeEntity> findUpgrades(long clusterId); @RequiresSession UpgradeEntity findUpgrade(long upgradeId); @RequiresSession UpgradeEntity findUpgradeByRequestId(Long requestId); @Transactional void create(UpgradeEntity entity); @Transactional void removeAll(long clusterId); @RequiresSession UpgradeGroupEntity findUpgradeGroup(Long groupId); @RequiresSession UpgradeItemEntity findUpgradeItem(long itemId); @RequiresSession UpgradeItemEntity findUpgradeItemByRequestAndStage(Long requestId, Long stageId); @RequiresSession UpgradeEntity findLastUpgradeForCluster(long clusterId, Direction direction); @RequiresSession UpgradeEntity findLastUpgradeOrDowngradeForCluster(long clusterId); @Transactional UpgradeEntity merge(UpgradeEntity upgradeEntity); }
UpgradeDAO { @RequiresSession public UpgradeEntity findUpgrade(long upgradeId) { TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery( "UpgradeEntity.findUpgrade", UpgradeEntity.class); query.setParameter("upgradeId", Long.valueOf(upgradeId)); return daoUtils.selectSingle(query); }  @RequiresSession List<UpgradeEntity> findAll(); @RequiresSession List<UpgradeEntity> findUpgrades(long clusterId); @RequiresSession UpgradeEntity findUpgrade(long upgradeId); @RequiresSession UpgradeEntity findUpgradeByRequestId(Long requestId); @Transactional void create(UpgradeEntity entity); @Transactional void removeAll(long clusterId); @RequiresSession UpgradeGroupEntity findUpgradeGroup(Long groupId); @RequiresSession UpgradeItemEntity findUpgradeItem(long itemId); @RequiresSession UpgradeItemEntity findUpgradeItemByRequestAndStage(Long requestId, Long stageId); @RequiresSession UpgradeEntity findLastUpgradeForCluster(long clusterId, Direction direction); @RequiresSession UpgradeEntity findLastUpgradeOrDowngradeForCluster(long clusterId); @Transactional UpgradeEntity merge(UpgradeEntity upgradeEntity);  }