if (slashIndex != -1) {
hostName = nodeId.substring(0, slashIndex);
}
final ComputeHost host = getOrCreateComputeHost(hostName);
ComputeNode node = getHibernateTemplate().execute(new HibernateCallback<ComputeNode>() {
@Override
public ComputeNode doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.getNamedQuery("ComputeNode.one.byNodeName");
query.setString("nodeName", nodeId);
return (ComputeNode) query.uniqueResult();
}
});
if (node == null) {
node = new ComputeNode();
node.setComputeHost(host);
node.setNodeName(nodeId);
getHibernateTemplate().save(node);
getHibernateTemplate().flush();
}
return node;
}