Skip to content

Commit

Permalink
use selected query
Browse files Browse the repository at this point in the history
  • Loading branch information
mbussolotto committed Nov 14, 2024
1 parent 592ab3d commit baa217e
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.query.SelectionQuery;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -78,19 +79,18 @@ public static ChannelFamily lookupById(Long id) {
* @return the ChannelFamily found
*/
public static ChannelFamily lookupByLabel(String label, Org org) {
String sql =
"SELECT * FROM rhnChannelFamily WHERE label = :label AND (org = :org OR org IS NULL)";
TypedQuery<ChannelFamily> query =
getSession().createNativeQuery(sql, ChannelFamily.class);
String sql = "FROM ChannelFamily WHERE label = :label AND (org = :org OR org IS NULL)";
SelectionQuery<ChannelFamily> query = getSession().createSelectionQuery(sql, ChannelFamily.class);
query.setParameter("label", label);
query.setParameter("org", org);
if (org != null) {
query.setParameter("org", org);
}

try {
return query.getSingleResult();
}
catch (NoResultException e) {
} catch (NoResultException e) {
return null;
}
catch (Exception e) {
} catch (Exception e) {
throw new RuntimeException("Error retrieving ChannelFamily", e);
}
}
Expand Down

0 comments on commit baa217e

Please sign in to comment.