}
});
}
protected ComputeHost getOrCreateComputeHost(final String hostName) {
ComputeHost computeHost = getHibernateTemplate().execute(new HibernateCallback<ComputeHost>() {
@Override
public ComputeHost doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.getNamedQuery("ComputeHost.one.byHostName");
query.setString("hostName", hostName);
return (ComputeHost) query.uniqueResult();
}
});
if (computeHost == null) {
computeHost = new ComputeHost();
computeHost.setHostName(hostName);
getHibernateTemplate().save(computeHost);
getHibernateTemplate().flush();
}
return computeHost;
}