if (results.size() != 0)
{
throw new IdentityException("Relationship already present");
}
HibernateIdentityObjectRelationship relationship = null;
if (name != null)
{
HibernateIdentityObjectRelationshipName relationshipName =
(HibernateIdentityObjectRelationshipName)getHibernateSession(ctx).
createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name)).
uniqueResult();
if (relationshipName == null)
{
throw new IdentityException("Relationship name not present in the store");
}
relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO, relationshipName);
}
else
{
relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO);
}
getHibernateSession(ctx).persist(relationship);
return relationship;