java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java | 13 +++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit ce2ab2d821d57702769c8205ad7d054b1c0f14df
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Tue Mar 29 10:40:11 2011 +0200
664715 - catch exception, if no data found
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
index c0ecbd7..be2f138 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
@@ -29,6 +29,8 @@ import com.redhat.rhn.domain.user.User;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.hibernate.ObjectNotFoundException;
+import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
@@ -378,15 +380,20 @@ public class ConfigurationFactory extends HibernateFactory {
*/
public static ConfigFile lookupConfigFileByChannelAndName(Long channel, Long name) {
Session session = HibernateFactory.getSession();
- return (ConfigFile)
+ Query query =
session.getNamedQuery("ConfigFile.findByChannelAndName")
.setLong("channel_id", channel.longValue())
.setLong("name_id", name.longValue())
.setLong("state_id", ConfigFileState.normal().
getId().longValue())
//Retrieve from cache if there
- .setCacheable(true)
- .uniqueResult();
+ .setCacheable(true);
+ try {
+ return (ConfigFile) query.uniqueResult();
+ }
+ catch (ObjectNotFoundException e) {
+ return null;
+ }
}
/**
Show replies by date