public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException { if ( isAbstractClass(clazz) ) return null; try { Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES); if ( !isPublic(clazz, constructor) ) { constructor.setAccessible(true); } return constructor; } catch (NoSuchMethodException nme) { throw new PropertyNotFoundException( "Object class " + clazz.getName() + " must declare a default (no-argument) constructor" ); } }
public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException { if ( isAbstractClass(clazz) ) return null; try { Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES); if ( !isPublic(clazz, constructor) ) { constructor.setAccessible(true); } return constructor; } catch (NoSuchMethodException nme) { throw new PropertyNotFoundException( "Object class " + clazz.getName() + " must declare a default (no-argument) constructor" ); } }
public Object instantiate() { if ( ReflectHelper.isAbstractClass(mappedClass) ) { throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass ); } else if ( optimizer != null ) { return optimizer.newInstance(); } else if ( constructor == null ) { throw new InstantiationException( "No default constructor for entity: ", mappedClass ); } else { try { return constructor.newInstance( null ); } catch ( Exception e ) { throw new InstantiationException( "Could not instantiate entity: ", mappedClass, e ); } } }
public Object instantiate() { if ( ReflectHelper.isAbstractClass(mappedClass) ) { throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass ); } else if ( fastClass != null ) { try { return fastClass.newInstance(); } catch ( Throwable t ) { throw new InstantiationException( "Could not instantiate entity with CGLIB: ", mappedClass, t ); } } else if ( constructor == null ) { throw new InstantiationException( "No default constructor for entity: ", mappedClass ); } else { try { return constructor.newInstance( null ); } catch ( Exception e ) { throw new InstantiationException( "Could not instantiate entity: ", mappedClass, e ); } } }
isAbstract = persistentClass.isAbstract() || ( persistentClass.hasPojoRepresentation() && ReflectHelper.isAbstractClass( persistentClass.getMappedClass() ) ); selectBeforeUpdate = persistentClass.hasSelectBeforeUpdate();