List of usage examples for org.hibernate NonUniqueObjectException NonUniqueObjectException
public NonUniqueObjectException(String message, Serializable entityId, String entityName)
From source file:com.abiquo.server.core.appslibrary.VirtualImageConversionDAO.java
License:Open Source License
@Deprecated // use selectConversion TODO delthis @SuppressWarnings("unchecked") public VirtualImageConversion getUnbundledConversion(final VirtualMachineTemplate image, final DiskFormatType format) { // There can be no images List<VirtualImageConversion> conversions = createCriteria(sameImage(image)).add(targetFormatIn(format)) .add(sourceFormatNull()).list(); // Are there any? if (conversions != null && !conversions.isEmpty()) { // This function should be returning the only object if (conversions.size() > 1) { throw new NonUniqueObjectException("There is more than one conversion!", image.getId(), VirtualImageConversion.class.getSimpleName()); }/*from w ww.j a va 2s . c o m*/ return conversions.get(0); } return null; }