Skip to content

Commit

Permalink
fix parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
mbussolotto committed Aug 20, 2024
1 parent 9c362f3 commit 0012f2d
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void testLongField() {
TestObject to = new TestObject();
to.setLongField(10L);
assertNull(validator.validate("longField", to));
to.setLongField(100L);
to.setParameterField(100L);
assertNotNull(validator.validate("longField", to));
to.setThirdLongField(Long.MAX_VALUE);
assertNull(validator.validate("thirdLongFiled", to));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testFindByLabel() throws Exception {
private ActionType lookupByLabel(String label) {
Session session = HibernateFactory.getSession();
return (ActionType) session.getNamedQuery("ActionType.findByLabel")
.setString("label", label)
.setParameter("label", label)
//Retrieve from cache if there
.setCacheable(true)
.uniqueResult();
Expand Down
4 changes: 2 additions & 2 deletions java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public static void delete(XccdfTestResult tr) {
public static void clearTestResult(long serverId, long actionId) {
List<XccdfTestResult> results = getSession()
.getNamedQuery("XccdfTestResult.findByActionId")
.setLong("serverId", serverId)
.setLong("actionId", actionId)
.setParameter("serverId", serverId)
.setParameter("actionId", actionId)
.list();
results.forEach(ScapFactory::delete);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ public static Package lookupPackageByFilename(Channel channel,

List<Package> pkgs = HibernateFactory.getSession()
.getNamedQuery("Channel.packageByFileName")
.setString("pathlike", "%/" + fileName)
.setLong("channel_id", channel.getId())
.setParameter("pathlike", "%/" + fileName)
.setParameter("channel_id", channel.getId())
.list();
if (pkgs.isEmpty()) {
return null;
Expand All @@ -1081,8 +1081,8 @@ public static Package lookupPackageByFilenameAndRange(Channel channel,

List<Package> pkgs = HibernateFactory.getSession()
.getNamedQuery("Channel.packageByFileNameAndRange")
.setString("pathlike", "%/" + fileName)
.setLong("channel_id", channel.getId())
.setParameter("pathlike", "%/" + fileName)
.setParameter("channel_id", channel.getId())
.setInteger("headerStart", headerStart)
.setInteger("headerEnd", headerEnd)
.list();
Expand Down
8 changes: 4 additions & 4 deletions java/code/src/com/redhat/rhn/domain/common/CommonFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public static FileList lookupFileList(Long idIn, Org org) {
//look for Kickstart data by id
session = HibernateFactory.getSession();
return (FileList) session.getNamedQuery("FileList.findByIdAndOrg")
.setLong("id", idIn)
.setLong("org_id", org.getId())
.setParameter("id", idIn)
.setParameter("org_id", org.getId())
.uniqueResult();
}

Expand All @@ -103,8 +103,8 @@ public static FileList lookupFileList(String labelIn, Org org) {
Session session = null;
//look for Kickstart data by label
session = HibernateFactory.getSession();
return (FileList) session.getNamedQuery("FileList.findByLabelAndOrg").setString("label", labelIn)
.setLong("org_id", org.getId()).uniqueResult();
return (FileList) session.getNamedQuery("FileList.findByLabelAndOrg").setParameter("label", labelIn)
.setParameter("org_id", org.getId()).uniqueResult();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ public static ConfigFile lookupConfigFileByChannelAndName(Long channel, Long nam
Session session = HibernateFactory.getSession();
Query<ConfigFile> query =
session.getNamedQuery("ConfigFile.findByChannelAndName")
.setLong("channel_id", channel)
.setLong("name_id", name)
.setLong("state_id", ConfigFileState.normal().
.setParameter("channel_id", channel)
.setParameter("name_id", name)
.setParameter("state_id", ConfigFileState.normal().
getId());
try {
return query.uniqueResult();
Expand Down Expand Up @@ -463,7 +463,7 @@ public static ConfigRevision lookupConfigRevisionById(Long id) {
public static ConfigRevision lookupConfigRevisionByRevId(ConfigFile cf, Long revId) {
Session session = HibernateFactory.getSession();
Query<ConfigRevision> q = session.getNamedQuery("ConfigRevision.findByRevisionAndConfigFile");
q.setLong("rev", revId);
q.setParameter("rev", revId);
q.setParameter("cf", cf);
return q.uniqueResult();
}
Expand Down Expand Up @@ -514,7 +514,7 @@ static ConfigChannelType lookupConfigChannelTypeByLabel(String label) {
Session session = HibernateFactory.getSession();
return (ConfigChannelType)
session.getNamedQuery("ConfigChannelType.findByLabel")
.setString("label", label)
.setParameter("label", label)
//Retrieve from cache if there
.setCacheable(true)
.uniqueResult();
Expand All @@ -531,7 +531,7 @@ static ConfigChannelType lookupConfigChannelTypeByLabel(String label) {
static ConfigFileState lookupConfigFileStateByLabel(String label) {
Session session = HibernateFactory.getSession();
return (ConfigFileState)session.getNamedQuery("ConfigFileState.findByLabel")
.setString("label", label)
.setParameter("label", label)
//Retrieve from cache if there
.setCacheable(true)
.uniqueResult();
Expand All @@ -545,7 +545,7 @@ static ConfigFileState lookupConfigFileStateByLabel(String label) {
static ConfigFileType lookupConfigFileTypeByLabel(String label) {
Session session = HibernateFactory.getSession();
return (ConfigFileType)session.getNamedQuery("ConfigFileType.findByLabel")
.setString("label", label)
.setParameter("label", label)
//Retrieve from cache if there
.setCacheable(true)
.uniqueResult();
Expand Down
10 changes: 5 additions & 5 deletions java/code/src/com/redhat/rhn/domain/errata/ErrataFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public static ErrataFileType lookupErrataFileType(String label) {
ErrataFileType retval;
try {
retval = (ErrataFileType) getSession().getNamedQuery("ErrataFileType.findByLabel")
.setString("label", label).setCacheable(true).uniqueResult();
.setParameter("label", label).setCacheable(true).uniqueResult();
}
catch (HibernateException e) {
throw new HibernateRuntimeException(e.getMessage(), e);
Expand All @@ -415,8 +415,8 @@ public static List<ErrataFile> lookupErrataFilesByErrataAndFileType(Long errataI
List<ErrataFile> retval;
try {
Query<ErrataFile> q = getSession().getNamedQuery("ErrataFile.listByErrataAndFileType");
q.setLong("errata_id", errataId);
q.setString("file_type", fileType.toUpperCase());
q.setParameter("errata_id", errataId);
q.setParameter("file_type", fileType.toUpperCase());
retval = q.list();
}
catch (HibernateException e) {
Expand Down Expand Up @@ -447,7 +447,7 @@ public static List<Errata> lookupErratasByAdvisoryType(String advisoryType) {
List<Errata> retval;
try {
retval = getSession().getNamedQuery("Errata.findByAdvisoryType")
.setString("type", advisoryType)
.setParameter("type", advisoryType)
//Retrieve from cache if there
.setCacheable(true).list();
}
Expand All @@ -467,7 +467,7 @@ public static Errata lookupErrataById(Long id) {
Errata retval;
try {
retval = (Errata) getSession().getNamedQuery("Errata.findById")
.setLong("id", id).uniqueResult();
.setParameter("id", id).uniqueResult();
}
catch (HibernateException he) {
log.error("Error loading ActionArchTypes from DB", he);
Expand Down
60 changes: 30 additions & 30 deletions java/code/src/com/redhat/rhn/domain/kickstart/KickstartFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ else if (minor.contains("u")) {
public static KickstartData lookupKickstartDataByIdAndOrg(Org orgIn, Long ksid) {
return (KickstartData) HibernateFactory.getSession()
.getNamedQuery("KickstartData.findByIdAndOrg")
.setParameter("id", ksid, LongType.INSTANCE)
.setParameter(ORG_ID, orgIn.getId(), LongType.INSTANCE)
.setParameter("id", ksid)
.setParameter(ORG_ID, orgIn.getId())
.uniqueResult();
}

Expand All @@ -204,7 +204,7 @@ public static KickstartData lookupKickstartDataByCobblerIdAndOrg(Org orgIn,
return (KickstartData) HibernateFactory.getSession()
.getNamedQuery("KickstartData.findByCobblerIdAndOrg")
.setParameter("id", cobblerId)
.setParameter(ORG_ID, orgIn.getId(), LongType.INSTANCE)
.setParameter(ORG_ID, orgIn.getId())
.uniqueResult();
}

Expand All @@ -222,7 +222,7 @@ public static KickstartData lookupKickstartDataByLabelAndOrgId(
return (KickstartData) HibernateFactory.getSession().
getNamedQuery("KickstartData.findByLabelAndOrg")
.setParameter(LABEL, label)
.setParameter(ORG_ID, orgId, LongType.INSTANCE)
.setParameter(ORG_ID, orgId)
.uniqueResult();
}

Expand All @@ -241,7 +241,7 @@ public static KickstartData lookupKickstartDataByCILabelAndOrgId(
return (KickstartData) HibernateFactory.getSession().
getNamedQuery("KickstartData.findByCILabelAndOrg")
.setParameter(LABEL, label)
.setParameter(ORG_ID, orgId, LongType.INSTANCE)
.setParameter(ORG_ID, orgId)
.uniqueResult();
}

Expand Down Expand Up @@ -482,7 +482,7 @@ public static CryptoKey lookupCryptoKey(String description, Org org) {
if (org != null) {
query = session.getNamedQuery("CryptoKey.findByDescAndOrg")
.setParameter("description", description)
.setParameter(ORG_ID, org.getId(), LongType.INSTANCE);
.setParameter(ORG_ID, org.getId());
}
else {
query = session.getNamedQuery("CryptoKey.findByDescAndNullOrg")
Expand All @@ -500,7 +500,7 @@ public static List<CryptoKey> lookupCryptoKeys(Org org) {
//look for Kickstart data by id
Session session = HibernateFactory.getSession();
return session.getNamedQuery("CryptoKey.findByOrg")
.setParameter(ORG_ID, org.getId(), LongType.INSTANCE)
.setParameter(ORG_ID, org.getId())
.list();
}

Expand All @@ -513,7 +513,7 @@ public static List<SslCryptoKey> lookupSslCryptoKeys(Org org) {
//look for Kickstart data by id
Session session = HibernateFactory.getSession();
return session.getNamedQuery("SslCryptoKey.findByOrg")
.setParameter(ORG_ID, org.getId(), LongType.INSTANCE)
.setParameter(ORG_ID, org.getId())
.list();
}

Expand All @@ -527,8 +527,8 @@ public static CryptoKey lookupCryptoKeyById(Long keyId, Org org) {
//look for Kickstart data by id
Session session = HibernateFactory.getSession();
return (CryptoKey) session.getNamedQuery("CryptoKey.findByIdAndOrg")
.setParameter("key_id", keyId, LongType.INSTANCE)
.setParameter(ORG_ID, org.getId(), LongType.INSTANCE)
.setParameter("key_id", keyId)
.setParameter(ORG_ID, org.getId())
.uniqueResult();
}

Expand All @@ -542,8 +542,8 @@ public static SslCryptoKey lookupSslCryptoKeyById(Long keyId, Org org) {
//look for Kickstart data by id
Session session = HibernateFactory.getSession();
Query<SslCryptoKey> query = session.getNamedQuery("SslCryptoKey.findByIdAndOrg");
return query.setParameter("key_id", keyId, LongType.INSTANCE)
.setParameter(ORG_ID, org.getId(), LongType.INSTANCE)
return query.setParameter("key_id", keyId)
.setParameter(ORG_ID, org.getId())
.uniqueResult();
}

Expand Down Expand Up @@ -573,7 +573,7 @@ public static KickstartableTree lookupKickstartTreeByLabel(String label, Org org
KickstartableTree retval = (KickstartableTree)
session.getNamedQuery("KickstartableTree.findByLabelAndOrg")
.setParameter(LABEL, label)
.setParameter(ORG_ID, org.getId(), LongType.INSTANCE)
.setParameter(ORG_ID, org.getId())
.uniqueResult();
// If we don't find by label + org then
// we try by label and NULL org (RHN owned channel)
Expand Down Expand Up @@ -611,8 +611,8 @@ public static List<KickstartableTree> lookupKickstartTreesByChannelAndOrg(Long c
String query = "KickstartableTree.findByChannelAndOrg";
Session session = HibernateFactory.getSession();
return session.getNamedQuery(query).
setParameter("channel_id", channelId, LongType.INSTANCE).
setParameter(ORG_ID, org.getId(), LongType.INSTANCE)
setParameter("channel_id", channelId).
setParameter(ORG_ID, org.getId())
//Retrieve from cache if there
.setCacheable(true).list();
}
Expand All @@ -627,7 +627,7 @@ public static List<KickstartableTree> lookupKickstartTreesByChannelAndNullOrg(
String query = "KickstartableTree.findByChannelAndNullOrg";
Session session = HibernateFactory.getSession();
return session.getNamedQuery(query)
.setParameter("channel_id", channelId, LongType.INSTANCE)
.setParameter("channel_id", channelId)
// Retrieve from cache if there
.setCacheable(true).list();
}
Expand All @@ -648,8 +648,8 @@ public static List<KickstartableTree> lookupKickstartableTrees(
query = "KickstartableTree.findByChannel";
session = HibernateFactory.getSession();
retval = session.getNamedQuery(query).
setParameter("channel_id", channelId, LongType.INSTANCE).
setParameter(ORG_ID, org.getId(), LongType.INSTANCE).
setParameter("channel_id", channelId).
setParameter(ORG_ID, org.getId()).
list();
return retval;
}
Expand Down Expand Up @@ -713,8 +713,8 @@ public static KickstartableTree lookupKickstartTreeByIdAndOrg(Long treeId, Org o
if (treeId != null && org != null) {
Session session = HibernateFactory.getSession();
Query<KickstartableTree> query = session.getNamedQuery(queryName);
query.setParameter(ORG_ID, org.getId(), LongType.INSTANCE);
query.setParameter("tree_id", treeId, LongType.INSTANCE);
query.setParameter(ORG_ID, org.getId());
query.setParameter("tree_id", treeId);
//Retrieve from cache if there
return query.setCacheable(true).uniqueResult();
}
Expand All @@ -735,7 +735,7 @@ public static KickstartableTree lookupKickstartTreeByIdAndOrg(Long treeId, Org o
public static KickstartSession lookupKickstartSessionByServer(Long sidIn) {
Session session = HibernateFactory.getSession();
List<KickstartSession> ksessions = session.getNamedQuery("KickstartSession.findByServer")
.setParameter("server", sidIn, LongType.INSTANCE)
.setParameter("server", sidIn)
.list();
if (!ksessions.isEmpty()) {
return ksessions.iterator().next();
Expand All @@ -754,7 +754,7 @@ public static KickstartSession lookupKickstartSessionByServer(Long sidIn) {
Session session = HibernateFactory.getSession();
List<KickstartSession> ksessions = session.getNamedQuery(
"KickstartSession.findDefaultKickstartSessionForKickstartData")
.setParameter("ksdata", ksdata.getId(), LongType.INSTANCE)
.setParameter("ksdata", ksdata.getId())
.setParameter("mode", KickstartSession.MODE_DEFAULT_SESSION)
.list();
if (!ksessions.isEmpty()) {
Expand Down Expand Up @@ -793,7 +793,7 @@ public static void saveKickstartSession(KickstartSession ksession) {
public static List<KickstartSession> lookupAllKickstartSessionsByServer(Long sidIn) {
Session session = HibernateFactory.getSession();
return session.getNamedQuery("KickstartSession.findByServer")
.setParameter("server", sidIn, LongType.INSTANCE)
.setParameter("server", sidIn)
.list();
}

Expand Down Expand Up @@ -826,9 +826,9 @@ public static boolean verifyTreeAssignment(Long channelId, Long orgId, Long tree
Session session = HibernateFactory.getSession();
Query<KickstartableTree> query = session.
getNamedQuery("KickstartableTree.verifyTreeAssignment");
query.setParameter("channel_id", channelId, LongType.INSTANCE);
query.setParameter(ORG_ID, orgId, LongType.INSTANCE);
query.setParameter("tree_id", treeId, LongType.INSTANCE);
query.setParameter("channel_id", channelId);
query.setParameter(ORG_ID, orgId);
query.setParameter("tree_id", treeId);
KickstartableTree tree = query.uniqueResult();
return tree != null;
}
Expand Down Expand Up @@ -904,7 +904,7 @@ public static List<KickstartData> lookupKickstartDatasByTree(KickstartableTree t
String query = "KickstartData.lookupByTreeId";
Session session = HibernateFactory.getSession();
return session.getNamedQuery(query)
.setParameter("kstree_id", tree.getId(), LongType.INSTANCE)
.setParameter("kstree_id", tree.getId())
.list();
}

Expand Down Expand Up @@ -944,7 +944,7 @@ public static KickstartData lookupOrgDefault(Org org) {
return (KickstartData) session
.getNamedQuery("KickstartData.findOrgDefault")
.setParameter("org", org)
.setParameter("isOrgDefault", "Y", StringType.INSTANCE)
.setParameter("isOrgDefault", "Y")
.uniqueResult();
}

Expand Down Expand Up @@ -1074,8 +1074,8 @@ public static List<KickstartPackage> lookupKsPackageByKsDataAndPackageName(
KickstartData ksData, PackageName packageName) {
return HibernateFactory.getSession()
.getNamedQuery("KickstartPackage.findByKickstartDataAndPackageName")
.setParameter("ks_data", ksData.getId(), LongType.INSTANCE)
.setParameter("package_name", packageName.getId(), LongType.INSTANCE)
.setParameter("ks_data", ksData.getId())
.setParameter("package_name", packageName.getId())
.list();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private KickstartData lookupById(Org orgIn, Long id) {
Session session = HibernateFactory.getSession();
return (KickstartData) session.getNamedQuery("KickstartData.findByIdAndOrg")
.setParameter("id", id)
.setParameter("org_id", orgIn.getId(), LongType.INSTANCE)
.setParameter("org_id", orgIn.getId())
.uniqueResult();
}

Expand Down
Loading

0 comments on commit 0012f2d

Please sign in to comment.