public ClassDescriptor buildDatabaseLoginConfigDescriptor() { ClassDescriptor descriptor = super.buildDatabaseLoginConfigDescriptor(); XMLDirectMapping bindAllParametersMapping = (XMLDirectMapping) descriptor.getMappingForAttributeName("m_bindAllParameters"); bindAllParametersMapping.setNullValue(Boolean.valueOf(BIND_ALL_PARAMETERS_DEFAULT)); XMLDirectMapping validateConnectionHealthOnErrorMapping = new XMLDirectMapping(); validateConnectionHealthOnErrorMapping.setAttributeName("connectionHealthValidatedOnError"); validateConnectionHealthOnErrorMapping.setGetMethodName("isConnectionHealthValidatedOnError"); validateConnectionHealthOnErrorMapping.setSetMethodName("setConnectionHealthValidatedOnError"); validateConnectionHealthOnErrorMapping.setXPath("connection-health-validated-on-error/text()"); validateConnectionHealthOnErrorMapping.setNullPolicy(new NullPolicy(null, false, false, false)); validateConnectionHealthOnErrorMapping.setNullValue(true); descriptor.addMapping(validateConnectionHealthOnErrorMapping); XMLDirectMapping delayBetweenReconnectAttempts = new XMLDirectMapping(); delayBetweenReconnectAttempts.setAttributeName("delayBetweenConnectionAttempts"); delayBetweenReconnectAttempts.setGetMethodName("getDelayBetweenConnectionAttempts"); delayBetweenReconnectAttempts.setSetMethodName("setDelayBetweenConnectionAttempts"); delayBetweenReconnectAttempts.setXPath("delay-between-reconnect-attempts/text()"); delayBetweenReconnectAttempts.setNullPolicy(new NullPolicy(null, false, false, false)); descriptor.addMapping(delayBetweenReconnectAttempts); XMLDirectMapping queryRetryAttemptCount = new XMLDirectMapping(); queryRetryAttemptCount.setAttributeName("queryRetryAttemptCount"); queryRetryAttemptCount.setGetMethodName("getQueryRetryAttemptCount"); queryRetryAttemptCount.setSetMethodName("setQueryRetryAttemptCount"); queryRetryAttemptCount.setXPath("query-retry-attempt-count/text()"); queryRetryAttemptCount.setNullPolicy(new NullPolicy(null, false, false, false)); descriptor.addMapping(queryRetryAttemptCount); XMLDirectMapping pingSQLMapping = new XMLDirectMapping(); pingSQLMapping.setAttributeName("pingSQL"); pingSQLMapping.setGetMethodName("getPingSQL"); pingSQLMapping.setSetMethodName("setPingSQL"); pingSQLMapping.setXPath("ping-sql/text()"); pingSQLMapping.setNullPolicy(new NullPolicy(null, false, false, false)); descriptor.addMapping(pingSQLMapping); return descriptor; }
public ClassDescriptor buildXMLLoginConfigDescriptor() { ClassDescriptor descriptor = super.buildXMLLoginConfigDescriptor(); XMLDirectMapping equalNamespaceResolversMapping = new XMLDirectMapping(); equalNamespaceResolversMapping.setAttributeName("m_equalNamespaceResolvers"); equalNamespaceResolversMapping.setGetMethodName("getEqualNamespaceResolvers"); equalNamespaceResolversMapping.setSetMethodName("setEqualNamespaceResolvers"); equalNamespaceResolversMapping.setXPath("equal-namespace-resolvers/text()"); equalNamespaceResolversMapping.setNullValue(Boolean.TRUE); descriptor.addMapping(equalNamespaceResolversMapping); XMLCompositeObjectMapping documentPreservationPolicyMapping = new XMLCompositeObjectMapping(); documentPreservationPolicyMapping.setReferenceClass(DocumentPreservationPolicyConfig.class); documentPreservationPolicyMapping.setAttributeName("m_documentPreservationPolicy"); documentPreservationPolicyMapping.setGetMethodName("getDocumentPreservationPolicy"); documentPreservationPolicyMapping.setSetMethodName("setDocumentPreservationPolicy"); documentPreservationPolicyMapping.setXPath("document-preservation-policy"); descriptor.addMapping(documentPreservationPolicyMapping); return descriptor; }
protected void setup() { getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); descriptorToModify = (ClassDescriptor) project.getDescriptors().get(Employee.class); VariableOneToOneMapping typeMapping = new VariableOneToOneMapping(); typeMapping.setAttributeName("test"); typeMapping.setReferenceClass(Employee.class); typeMapping.setForeignQueryKeyName("T_ID", "id"); typeMapping.addTargetForeignQueryKeyName("testTargerFKQueryName", "testSourcePKFieldName"); typeMapping.dontUseIndirection(); typeMapping.privateOwnedRelationship(); descriptorToModify.addMapping(typeMapping); }
public void customize(ClassDescriptor descriptor) { // This maps the descriminator column in the vehicle subclass. TransformationMapping mapping = new TransformationMapping(); mapping.addFieldTransformer( "VEHICLEPOLICY.VEHICLE_TYPE", new FieldTransformerAdapter() { @Override public String buildFieldValue(Object policy, String column, Session session) { if (policy instanceof AutoPolicy) { return "AUTO"; } else if (policy instanceof MotorcyclePolicy) { return "MOTO"; } return null; } }); descriptor.addMapping(mapping); }