@Test public void testFindByName() throws Exception { createConfigGroup("c1", "hdfs-1", "HDFS", "some description", null, null); ConfigGroupEntity configGroupEntity = configGroupDAO.findByName("hdfs-1"); Long clusterId = clusterDAO.findByName("c1").getClusterId(); Assert.assertNotNull(configGroupEntity); Assert.assertEquals("c1", configGroupEntity.getClusterEntity().getClusterName()); Assert.assertEquals(clusterId, configGroupEntity.getClusterEntity() .getClusterId()); Assert.assertEquals("hdfs-1", configGroupEntity.getGroupName()); Assert.assertEquals("HDFS", configGroupEntity.getTag()); Assert.assertEquals("some description", configGroupEntity.getDescription()); }
@RequiresSession public ConfigGroupEntity findByName(String groupName) { TypedQuery<ConfigGroupEntity> query = entityManagerProvider.get() .createNamedQuery("configGroupByName", ConfigGroupEntity.class); query.setParameter("groupName", groupName); try { return query.getSingleResult(); } catch (NoResultException ignored) { return null; } }
ConfigGroupDAO { @RequiresSession public ConfigGroupEntity findByName(String groupName) { TypedQuery<ConfigGroupEntity> query = entityManagerProvider.get() .createNamedQuery("configGroupByName", ConfigGroupEntity.class); query.setParameter("groupName", groupName); try { return query.getSingleResult(); } catch (NoResultException ignored) { return null; } } }
ConfigGroupDAO { @RequiresSession public ConfigGroupEntity findByName(String groupName) { TypedQuery<ConfigGroupEntity> query = entityManagerProvider.get() .createNamedQuery("configGroupByName", ConfigGroupEntity.class); query.setParameter("groupName", groupName); try { return query.getSingleResult(); } catch (NoResultException ignored) { return null; } }  }
ConfigGroupDAO { @RequiresSession public ConfigGroupEntity findByName(String groupName) { TypedQuery<ConfigGroupEntity> query = entityManagerProvider.get() .createNamedQuery("configGroupByName", ConfigGroupEntity.class); query.setParameter("groupName", groupName); try { return query.getSingleResult(); } catch (NoResultException ignored) { return null; } }  @RequiresSession ConfigGroupEntity findByName(String groupName); @RequiresSession ConfigGroupEntity findById(Long id); @RequiresSession List<ConfigGroupEntity> findAll(); @RequiresSession List<ConfigGroupEntity> findAllByTag(String tag); @Transactional void create(ConfigGroupEntity configGroupEntity); @Transactional ConfigGroupEntity merge(ConfigGroupEntity configGroupEntity); @Transactional void remove(ConfigGroupEntity configGroupEntity); @Transactional void removeByPK(Long id); @Transactional void refresh(ConfigGroupEntity configGroupEntity); }
ConfigGroupDAO { @RequiresSession public ConfigGroupEntity findByName(String groupName) { TypedQuery<ConfigGroupEntity> query = entityManagerProvider.get() .createNamedQuery("configGroupByName", ConfigGroupEntity.class); query.setParameter("groupName", groupName); try { return query.getSingleResult(); } catch (NoResultException ignored) { return null; } }  @RequiresSession ConfigGroupEntity findByName(String groupName); @RequiresSession ConfigGroupEntity findById(Long id); @RequiresSession List<ConfigGroupEntity> findAll(); @RequiresSession List<ConfigGroupEntity> findAllByTag(String tag); @Transactional void create(ConfigGroupEntity configGroupEntity); @Transactional ConfigGroupEntity merge(ConfigGroupEntity configGroupEntity); @Transactional void remove(ConfigGroupEntity configGroupEntity); @Transactional void removeByPK(Long id); @Transactional void refresh(ConfigGroupEntity configGroupEntity);  }