コード例 #1
0
 @Override
 @SuppressWarnings("unchecked")
 public List<ChannelSeverity> retrieveByChannel(ChannelType channelType) {
   return sessionFactory
       .getCurrentSession()
       .createQuery(
           "from ChannelSeverity cs where cs.channelType = :channelTypeId order by cs.numericValue desc")
       .setInteger("channelTypeId", channelType.getId())
       .list();
 }
コード例 #2
0
  @Override
  public ChannelSeverity retrieveByCode(ChannelType channelType, String code) {

    // To avoid case insensitive query in MySQL
    List<ChannelSeverity> channelSeverities =
        (List<ChannelSeverity>)
            sessionFactory
                .getCurrentSession()
                .createQuery(
                    "from ChannelSeverity cs where cs.code = :code "
                        + "and cs.channelType = :channelTypeId")
                .setString("code", code)
                .setInteger("channelTypeId", channelType.getId())
                .list();

    if (channelSeverities == null || channelSeverities.size() == 0) return null;

    for (ChannelSeverity channelSeverity : channelSeverities) {
      if (code.equals(channelSeverity.getCode())) return channelSeverity;
    }

    return null;
  }