Example usage for org.hibernate NonUniqueObjectException NonUniqueObjectException

List of usage examples for org.hibernate NonUniqueObjectException NonUniqueObjectException

Introduction

In this page you can find the example usage for org.hibernate NonUniqueObjectException NonUniqueObjectException.

Prototype

public NonUniqueObjectException(String message, Serializable entityId, String entityName) 

Source Link

Document

Constructs a NonUniqueObjectException using the given information.

Usage

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;
}