/** * Return the default (zero-argument) constructor for the descriptor class. */ protected Constructor<?> getTypeConstructor() throws DescriptorException { if (this.constructor == null) { initialize(null); } return this.constructor; }
entity = (DynamicEntityImpl) PrivilegedAccessHelper.invokeConstructor(this.getTypeConstructor(), new Object[] { getType() }); } catch (InvocationTargetException exception) { throw DescriptorException.targetInvocationWhileConstructorInstantiation(this.getDescriptor(), exception); } catch (IllegalAccessException exception) { throw DescriptorException.illegalAccessWhileConstructorInstantiation(this.getDescriptor(), exception); } catch (InstantiationException exception) { throw DescriptorException.instantiationWhileConstructorInstantiation(this.getDescriptor(), exception); } catch (NoSuchMethodError exception) { throw DescriptorException.noSuchMethodWhileConstructorInstantiation(this.getDescriptor(), exception); } catch (NullPointerException exception) { throw DescriptorException.nullPointerWhileConstructorInstantiation(this.getDescriptor(), exception); for (DatabaseMapping mapping : getType().getMappingsRequiringInitialization()) { initializeValue(mapping, entity);
/** * Lookup the constructor. */ @Override public void initialize(AbstractSession session) throws DescriptorException { try { this.constructor = PrivilegedAccessHelper.getDeclaredConstructorFor(getType().getJavaClass(), new Class[] { DynamicTypeImpl.class }, true); this.constructor.setAccessible(true); } catch (NoSuchMethodException exception) { throw DescriptorException.noSuchMethodWhileInitializingInstantiationPolicy(getType().getName() + ".<Default Constructor>", getDescriptor(), exception); } }
/** * Initialize a new or existing descriptor configuring the necessary * policies as well as */ protected void configure(ClassDescriptor descriptor, String... tableNames) { // Configure Table names if provided if (tableNames != null) { if (tableNames.length == 0) { if (descriptor.getTables().size() == 0) { descriptor.descriptorIsAggregate(); } } else { for (int index = 0; index < tableNames.length; index++) { descriptor.addTableName(tableNames[index]); } } } descriptor.setObjectChangePolicy(new AttributeChangeTrackingPolicy()); descriptor.setInstantiationPolicy(new DynamicTypeInstantiationPolicy((DynamicTypeImpl) getType())); for (int index = 0; index < descriptor.getMappings().size(); index++) { addMapping((DatabaseMapping) descriptor.getMappings().get(index)); } descriptor.setProperty(DynamicTypeImpl.DESCRIPTOR_PROPERTY, entityType); }