This is a utility method intended provided to help the JPA module.
6398
public static IQueryParameterAnd<?> parseQueryParams(FhirContext theContext, RestSearchParameterTypeEnum paramType,
			String theUnqualifiedParamName, List<QualifiedParamList> theParameters) {
		QueryParameterAndBinder binder = null;
		switch (paramType) {
		case COMPOSITE:
			throw new UnsupportedOperationException();
		case DATE:
			binder = new QueryParameterAndBinder(DateAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case NUMBER:
			binder = new QueryParameterAndBinder(NumberAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case QUANTITY:
			binder = new QueryParameterAndBinder(QuantityAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case REFERENCE:
			binder = new QueryParameterAndBinder(ReferenceAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case STRING:
			binder = new QueryParameterAndBinder(StringAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case TOKEN:
			binder = new QueryParameterAndBinder(TokenAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case URI:
			binder = new QueryParameterAndBinder(UriAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		case HAS:
			binder = new QueryParameterAndBinder(HasAndListParam.class,
					Collections.<Class<? extends IQueryParameterType>> emptyList());
			break;
		}

		// FIXME null access
		return binder.parse(theContext, theUnqualifiedParamName, theParameters);
	}
1110406
@Override
    protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders)
    {
        if (!isUpdate)
        {
            r.db(entityMetadata.getSchema()).table(entityMetadata.getTableName())
                    .insert(populateRmap(entityMetadata, entity)).run(connection);
        }
        else
        {
            r.db(entityMetadata.getSchema()).table(entityMetadata.getTableName())
                    .update(populateRmap(entityMetadata, entity)).run(connection);
        }
    }
988882
private String getManyToOneFetch() {
        Assert.isTrue(relation.isManyToOne());
        return jpaFetch(this, relation.getFromAttribute().getColumnConfig().getManyToOneConfig(), //
                relation.getFromEntity().getConfig().getCelerio().getConfiguration().getDefaultManyToOneConfig());
    }
540186
protected void onSuperColumn(EntityMetadata m, boolean isRelation, List<String> relations, List<Object> entities,
        List<SuperColumn> superColumns, ByteBuffer key) {
        Object e = null;
        Object id = PropertyAccessorHelper.getObject(m.getIdAttribute().getJavaType(), key.array());

        ThriftRow tr = new ThriftRow(id, m.getTableName(), new ArrayList<Column>(0), superColumns,
            new ArrayList<CounterColumn>(0), new ArrayList<CounterSuperColumn>(0));

        e = getDataHandler().populateEntity(tr, m, KunderaCoreUtils.getEntity(e), relations, isRelation);
        if (log.isInfoEnabled()) {
            log.info("Populating data for super column family of clazz {} and row key {}.", m.getEntityClazz(),
                tr.getId());
        }

        if (e != null) {
            entities.add(e);
        }
    }
782372
@Override
   public void newManyToOneRelationship(
            final Project project,
            final JavaResource resource,
            final String fieldName,
            final String fieldType,
            final String inverseFieldName,
            final FetchType fetchType,
            final boolean required,
            final Iterable<CascadeType> cascadeTypes) throws FileNotFoundException
   {
      JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
      JavaClassSource many = getJavaClassFrom(resource);
      JavaClassSource one;
      if (areTypesSame(fieldType, many.getCanonicalName()))
      {
         one = many;
      }
      else
      {
         one = findEntity(project, fieldType);
         many.addImport(one);
      }
      if (many.hasField(fieldName))
      {
         throw new IllegalStateException("Entity [" + many.getCanonicalName() + "] already has a field named ["
                  + fieldName + "]");
      }
      if (!Strings.isNullOrEmpty(inverseFieldName) && one.hasField(inverseFieldName))
      {
         throw new IllegalStateException("Entity [" + one.getCanonicalName() + "] already has a field named ["
                  + inverseFieldName + "]");
      }

      FieldSource<JavaClassSource> manyField = many.addField("private " + one.getName() + " " + fieldName + ";");
      AnnotationSource<JavaClassSource> manyAnnotation = manyField.addAnnotation(ManyToOne.class);
      Refactory.createGetterAndSetter(many, manyField);

      if (!Strings.isNullOrEmpty(inverseFieldName))
      {
         one.addImport(Set.class);
         one.addImport(HashSet.class);
         if (!one.getCanonicalName().equals(many.getCanonicalName()))
         {
            one.addImport(many.getQualifiedName());
         }
         FieldSource<JavaClassSource> oneField = one.addField("private Set<" + many.getName() + "> " + inverseFieldName
                  + "= new HashSet<"
                  + many.getName() + ">();");
         AnnotationSource<JavaClassSource> oneAnnotation = oneField.addAnnotation(OneToMany.class).setStringValue(
                  "mappedBy",
                  fieldName);
         oneAnnotation.setLiteralValue("cascade", "CascadeType.ALL");
         oneAnnotation.getOrigin().addImport(CascadeType.class);

         Refactory.createGetterAndSetter(one, oneField);
         java.saveJavaSource(one);
      }

      if (fetchType != null && fetchType != FetchType.EAGER)
      {
         manyAnnotation.setEnumValue("fetch", fetchType);
      }
      if (required)
      {
         // Set the optional attribute of @OneToOne/@ManyToOne only when false, since the default value is true
         manyAnnotation.setLiteralValue("optional", "false");
      }
      addCascade(cascadeTypes, manyAnnotation);
      java.saveJavaSource(many);
   }
599637
private void addToWrapper(EntityMetadata entityMetadata, AttributeWrapper wrapper, Object resultedObject,
            Attribute attrib)
    {
        addToWrapper(entityMetadata, wrapper, resultedObject, attrib, null);
    }
752199
private static PersistenceStrategy<?, ?, ?> getPerTableStrategy(
			EmbeddedCacheManager externalCacheManager,
			URL configUrl,
			JtaPlatform platform,
			Set<EntityKeyMetadata> entityTypes,
			Set<AssociationKeyMetadata> associationTypes,
			Set<IdSourceKeyMetadata> idSourceTypes) {

		PerTableKeyProvider keyProvider = new PerTableKeyProvider();

		PerTableCacheManager cacheManager = externalCacheManager != null ?
				new PerTableCacheManager( externalCacheManager, entityTypes, associationTypes, idSourceTypes ) :
				new PerTableCacheManager( configUrl, platform, entityTypes, associationTypes, idSourceTypes );

		return new PersistenceStrategy<PersistentEntityKey, PersistentAssociationKey, PersistentIdSourceKey>( cacheManager, keyProvider );
	}
1181504
@Bean
    @ConditionalOnMissingBean
    SoftwareModuleTypeManagement softwareModuleTypeManagement(
            final DistributionSetTypeRepository distributionSetTypeRepository,
            final SoftwareModuleTypeRepository softwareModuleTypeRepository,
            final VirtualPropertyReplacer virtualPropertyReplacer,
            final SoftwareModuleRepository softwareModuleRepository, final NoCountPagingRepository criteriaNoCountDao,
            final JpaProperties properties) {
        return new JpaSoftwareModuleTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
                virtualPropertyReplacer, softwareModuleRepository, criteriaNoCountDao, properties.getDatabase());
    }
581272
private void generateInsert(M2MEntity entity, String packageName) {
		if (!isMethodAlreadyDefined(entity, "insert")) {
			// @formatter:off
			MethodSpec methodSpec = MethodSpec.methodBuilder("insert").addModifiers(Modifier.PUBLIC)
					.addModifiers(Modifier.ABSTRACT).addAnnotation(AnnotationSpec.builder(BindSqlInsert.class).build())
					.addParameter(ParameterSpec.builder(TypeUtility.className(packageName, entity.name), "bean")
							.addAnnotation(
									AnnotationSpec.builder(BindSqlParam.class).addMember("value", "$S", "bean").build())
							.build())
					.returns(Integer.TYPE).build();
			// @formatter:on
			classBuilder.addMethod(methodSpec);
		}
	}
642703
private void populateCollectionFromJoinTable(Object entity, EntityMetadata entityMetadata,
            PersistenceDelegator delegator, Relation relation)
    {
        JoinTableMetadata jtMetadata = relation.getJoinTableMetadata();
        Client pClient = delegator.getClient(entityMetadata);

        String schema = entityMetadata.getSchema();

        EntityMetadata owningEntityMetadata = KunderaMetadataManager.getEntityMetadata(delegator.getKunderaMetadata(),
                relation.getTargetEntity());
        Class columnJavaType = owningEntityMetadata.getIdAttribute().getJavaType();
        if (jtMetadata == null)
        {
            columnJavaType = entityMetadata.getIdAttribute().getJavaType();
            Relation owningEntityMetadataRelation = owningEntityMetadata.getRelation(relation.getMappedBy());
            jtMetadata = owningEntityMetadataRelation.getJoinTableMetadata();
            pClient = delegator.getClient(owningEntityMetadata);
            schema = owningEntityMetadata.getSchema();
        }

        String joinTableName = jtMetadata.getJoinTableName();

        Set<String> joinColumns = jtMetadata.getJoinColumns();
        Set<String> inverseJoinColumns = jtMetadata.getInverseJoinColumns();

        String joinColumnName = (String) joinColumns.toArray()[0];
        String inverseJoinColumnName = (String) inverseJoinColumns.toArray()[0];

        Object entityId = PropertyAccessorHelper.getId(entity, entityMetadata);
        List<?> foreignKeys = pClient.getColumnsById(schema, joinTableName, joinColumnName, inverseJoinColumnName,
                entityId, columnJavaType);

        List childrenEntities = new ArrayList();

        if (foreignKeys != null)
        {
            for (Object foreignKey : foreignKeys)
            {
                EntityMetadata childMetadata = KunderaMetadataManager.getEntityMetadata(delegator.getKunderaMetadata(),
                        relation.getTargetEntity());

                Object child = delegator.find(relation.getTargetEntity(), foreignKey);
                Object obj = child instanceof EnhanceEntity && child != null ? ((EnhanceEntity) child).getEntity()
                        : child;

                // If child has any bidirectional relationship, process them
                // here
                Field biDirectionalField = relation.getBiDirectionalField();
                boolean isBidirectionalRelation = (biDirectionalField != null);

                if (isBidirectionalRelation && obj != null)
                {
                    Object columnValue = PropertyAccessorHelper.getId(obj, childMetadata);
                    Object[] pKeys = pClient.findIdsByColumn(entityMetadata.getSchema(), joinTableName, joinColumnName,
                            inverseJoinColumnName, columnValue, entityMetadata.getEntityClazz());
                    List parents = delegator.find(entity.getClass(), pKeys);
                    PropertyAccessorHelper.set(obj, biDirectionalField,
                            ObjectUtils.getFieldInstance(parents, biDirectionalField));
                    PersistenceCacheManager.addEntityToPersistenceCache(obj, delegator, columnValue);
                }

                childrenEntities.add(obj);
            }
        }
        Field childField = relation.getProperty();

        try
        {
            PropertyAccessorHelper.set(
                    entity,
                    childField,
                    PropertyAccessorHelper.isCollection(childField.getType()) ? ObjectUtils.getFieldInstance(
                            childrenEntities, childField) : childrenEntities.get(0));
            PersistenceCacheManager.addEntityToPersistenceCache(entity, delegator, entityId);
        }
        catch (PropertyAccessException ex)
        {
            throw new EntityReaderException(ex);
        }
    }
743946
function () {
            var bindings = this._bindings;
            for (var refpath in bindings) {
                if (bindings.hasOwnProperty(refpath)) {
                    var moduleBindings = bindings[refpath];
                    for (var bind in moduleBindings) {
                        if (moduleBindings.hasOwnProperty(bind)) {
                            var moduleDataDescription = this._getModuleDataDescription(refpath, bind);
                            var location = this._getStorage(moduleBindings[bind][0]);
                            var storedValue = this._utils.resolvePath(location.path, location.storage);
                            this.json.setValue(moduleDataDescription.container, moduleDataDescription.property, storedValue, moduleBindings[bind][1]);
                        }
                    }
                }
            }
        }
758342
private <X> void populateRelationMetaData(EntityType entityType, Class<X> clazz, EntityMetadata metadata)
    {
        Set<Attribute> attributes = entityType.getAttributes();

        for (Attribute attribute : attributes)
        {
            if (attribute.isAssociation())
            {

                addRelationIntoMetadata(clazz, (Field) attribute.getJavaMember(), metadata);
            }
        }

    }
66336
public static void generateLogForModifiers(final SQLiteModelMethod method, MethodSpec.Builder methodBuilder) {
		JQLChecker jqlChecker = JQLChecker.getInstance();

		final One<Boolean> usedInWhere = new One<Boolean>(false);

		methodBuilder.addCode("\n// display log\n");
		String sqlForLog = jqlChecker.replace(method, method.jql, new JQLReplacerListenerImpl(method) {
			@Override
			public String onColumnNameToUpdate(String columnName) {
				// only entity's columns
				return currentEntity.findPropertyByName(columnName).columnName;
			}

			@Override
			public String onColumnName(String columnName) {
				// return entity.findByName(columnName).columnName;
				return currentSchema.findColumnNameByPropertyName(method, columnName);
			}

			@Override
			public String onBindParameter(String bindParameterName, boolean inStatement) {

				if (usedInWhere.value0) {
					return "?";
				} else {
					String paramName = bindParameterName;
					if (paramName.contains(".")) {
						String[] a = paramName.split("\\.");

						if (a.length == 2) {
							paramName = a[1];
						}
					}

					SQLProperty property = currentEntity.findPropertyByName(paramName);
					AssertKripton.assertTrueOrUnknownPropertyInJQLException(property != null, method,
							bindParameterName);

					return ":" + property.columnName;
				}
			}

			@Override
			public void onWhereStatementBegin(Where_stmtContext ctx) {
				usedInWhere.value0 = true;
			}

			@Override
			public void onWhereStatementEnd(Where_stmtContext ctx) {
				usedInWhere.value0 = false;
			}

		});

		if (method.jql.dynamicReplace.containsKey(JQLDynamicStatementType.DYNAMIC_WHERE)) {
			methodBuilder.addStatement("$T.info($S, $L)", Logger.class,
					sqlForLog.replace(method.jql.dynamicReplace.get(JQLDynamicStatementType.DYNAMIC_WHERE), "%s"),
					"StringUtils.ifNotEmptyAppend(_sqlDynamicWhere,\" AND \")");
		} else {
			methodBuilder.addStatement("$T.info($S)", Logger.class, sqlForLog);
		}
	}
1284097
private static void generateReadMethod(PrefsEntity entity) {
		// read method
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("read").addModifiers(Modifier.PUBLIC).addJavadoc("read bean entirely\n\n").addJavadoc("@return read bean\n")
				.returns(typeName(entity.getName()));

		// immutable management
		if (entity.isImmutablePojo()) {
			methodBuilder.addCode("\n");
			methodBuilder.addComment("initialize temporary variable for immutable POJO");
			ImmutableUtility.generateImmutableVariableInit(entity, methodBuilder);
		} else {
			methodBuilder.addStatement("$T bean=new $T()", typeName(entity.getName()), typeName(entity.getName()));
		}

		PrefsTransform transform;

		for (PrefsProperty item : entity.getCollection()) {
			if (item.hasTypeAdapter()) {
				transform = PrefsTransformer.lookup(item.typeAdapter.getDataTypeTypename());
			} else {
				transform = PrefsTransformer.lookup(item);
			}

			if (entity.isImmutablePojo()) {
				transform.generateReadProperty(methodBuilder, "prefs", typeName(item.getElement().asType()), null, item, true, ReadType.NONE);
			} else {
				transform.generateReadProperty(methodBuilder, "prefs", typeName(item.getElement().asType()), "bean", item, true, ReadType.NONE);
			}

			methodBuilder.addCode("\n");
		}

		// immutable management
		if (entity.isImmutablePojo()) {
			methodBuilder.addComment("reset temporary variable for immutable POJO");
			ImmutableUtility.generateImmutableEntityCreation(entity, methodBuilder, "bean", true);
		}

		methodBuilder.addCode("\n");
		methodBuilder.addStatement("return bean");
		builder.addMethod(methodBuilder.build());
	}
976759
private static void generateInsertForContentProvider(TypeSpec.Builder classBuilder, final SQLiteModelMethod method,
			InsertType insertResultType) {
		final SQLiteDaoDefinition daoDefinition = method.getParent();
		final SQLiteEntity entity = method.getEntity();
		final Set<String> columns = new LinkedHashSet<>();

		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(method.contentProviderMethodName);
		if (!method.getParent().hasSamePackageOfSchema()) {
			methodBuilder.addModifiers(Modifier.PUBLIC);
		}

		ParameterSpec parameterSpec;
		parameterSpec = ParameterSpec.builder(Uri.class, "uri").build();
		methodBuilder.addParameter(parameterSpec);
		parameterSpec = ParameterSpec.builder(ContentValues.class, "contentValues").build();
		methodBuilder.addParameter(parameterSpec);
		methodBuilder.returns(Long.TYPE);

		SqlBuilderHelper.generateLogForContentProviderBeginning(method, methodBuilder);

		// just detect which columns are admitted
		JQLChecker.getInstance().replace(method, method.jql, new JQLReplacerListenerImpl(method) {

			@Override
			public String onColumnName(String columnName) {
				SQLProperty tempProperty = entity.get(columnName);
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, columnName);

				columns.add(tempProperty.columnName);

				return tempProperty.columnName;

			}

			@Override
			public String onColumnFullyQualifiedName(String tableName, String columnName) {
				AssertKripton.fail("Inconsistent state");
				return null;
			}

		});

		// generate columnCheckSet
		SqlBuilderHelper.generateColumnCheckSet(classBuilder, method, columns);

		// retrieve content values
		methodBuilder.addStatement("$T _contentValues=contentValuesForContentProvider(contentValues)",
				KriptonContentValues.class);

		// generate column check
		SqlBuilderHelper.forEachColumnInContentValue(methodBuilder, method, "_contentValues.values().keySet()", true,
				null);

		methodBuilder.addCode("\n");

		String rxIdGetter = "result";

		// extract pathVariables
		// generate get uri variables in content values
		// every controls was done in constructor of SQLiteModelMethod
		for (ContentUriPlaceHolder variable : method.contentProviderUriVariables) {
			SQLProperty entityProperty = entity.get(variable.value);

			if (entityProperty != null) {
				methodBuilder.addCode("// Add parameter $L at path segment $L\n", variable.value,
						variable.pathSegmentIndex);
				TypeName entityPropertyType = entityProperty.getPropertyType().getTypeName();
				if (TypeUtility.isString(entityPropertyType)) {
					methodBuilder.addStatement("contentValues.put($S, uri.getPathSegments().get($L))",
							entityProperty.columnName, variable.pathSegmentIndex);
				} else {
					methodBuilder.addStatement("contentValues.put($S, Long.valueOf(uri.getPathSegments().get($L)))",
							entityProperty.columnName, variable.pathSegmentIndex);
				}
			}

			if (entityProperty.isPrimaryKey()) {
				rxIdGetter = PropertyUtility.getter(entityProperty);
			}
		}

		// generate log for inser operation
		SqlBuilderHelper.generateLogForContentValuesContentProvider(method, methodBuilder);

		ConflictAlgorithmType conflictAlgorithmType = InsertBeanHelper.getConflictAlgorithmType(method);
		String conflictString1 = "";
		String conflictString2 = "";
		if (conflictAlgorithmType != ConflictAlgorithmType.NONE) {
			conflictString1 = "WithOnConflict";
			conflictString2 = ", " + conflictAlgorithmType.getConflictAlgorithm();
			methodBuilder.addCode("// conflict algorithm $L\n", method.jql.conflictAlgorithmType);
		}

		methodBuilder.addComment("insert operation");
		methodBuilder.addStatement("long result = database().insert$L($S, null, _contentValues.values()$L)",
				conflictString1, entity.getTableName(), conflictString2);
		if (method.getParent().getParent().generateRx) {
			SQLProperty primaryKey = entity.getPrimaryKey();
			if (primaryKey.columnType == ColumnType.PRIMARY_KEY) {
				// long autogenerated
				rxIdGetter = "result";
			} else {

				if (primaryKey.isType(String.class)) {
					rxIdGetter = String.format("contentValues.getAsString(\"%s\")", primaryKey.columnName);
				} else {
					rxIdGetter = String.format("contentValues.getAsLong(\"%s\")", primaryKey.columnName);
				}
			}

			GenericSQLHelper.generateSubjectNext(entity, methodBuilder, SubjectType.INSERT, rxIdGetter);
		}

		// support for livedata
		if (daoDefinition.hasLiveData()) {
			methodBuilder.addComment("support for livedata");
			methodBuilder.addStatement(BindDaoBuilder.METHOD_NAME_REGISTRY_EVENT + "(result>0?1:0)");
		}

		methodBuilder.addStatement("return result");

		// javadoc
		// we add at last javadoc, because need info is built at last.
		SqlBuilderHelper.generateJavaDocForContentProvider(method, methodBuilder);

		methodBuilder.addJavadoc("@param uri $S\n", method.contentProviderUriTemplate.replace("*", "[*]"));
		methodBuilder.addJavadoc("@param contentValues content values\n");

		methodBuilder.addJavadoc("@return new row's id\n");

		classBuilder.addMethod(methodBuilder.build());
	}
317403
public void generateJavaDoc(MethodSpec.Builder methodBuilder, final SQLiteModelMethod method, TypeName returnType,
			List<SQLProperty> listUsedProperty, ModelProperty primaryKey) {
		// transform JQL to SQL
		String sqlInsert = JQLChecker.getInstance().replace(method, method.jql, new JQLReplacerListenerImpl(method) {

			@Override
			public String onColumnName(String columnName) {
				Set<SQLProperty> property = currentSchema.getPropertyBySimpleName(columnName);

				SQLProperty tempProperty = property.iterator().next();
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, columnName);

				return tempProperty.columnName;
			}

			@Override
			public String onBindParameter(String bindParameterName, boolean inStatement) {
				String resolvedParamName = method.findParameterNameByAlias(bindParameterName);

				return SqlAnalyzer.PARAM_PREFIX + resolvedParamName + SqlAnalyzer.PARAM_SUFFIX;
			}

		});

		// generate javadoc and result
		{
			String beanNameParameter = method.findParameterAliasByName(method.getParameters().get(0).value0);

			methodBuilder.addJavadoc("<h2>SQL insert</h2>\n");
			methodBuilder.addJavadoc("<pre>$L</pre>\n\n", sqlInsert);
			methodBuilder.addJavadoc(
					"<p><code>$L.$L</code> is automatically updated because it is the primary key</p>\n",
					beanNameParameter, primaryKey.getName());
			methodBuilder.addJavadoc("\n");

			// list of inserted fields
			methodBuilder.addJavadoc("<p><strong>Inserted columns:</strong></p>\n");
			methodBuilder.addJavadoc("<dl>\n");
			for (SQLProperty property : listUsedProperty) {
				methodBuilder.addJavadoc("\t<dt>$L</dt>", property.columnName);
				methodBuilder.addJavadoc("<dd>is mapped to <strong>$L</strong></dd>\n",
						SqlAnalyzer.PARAM_PREFIX + method.findParameterAliasByName(method.getParameters().get(0).value0)
								+ "." + method.findParameterNameByAlias(property.getName()) + SqlAnalyzer.PARAM_SUFFIX);
			}
			methodBuilder.addJavadoc("</dl>\n\n");

			// update bean have only one parameter: the bean to update
			for (Pair<String, TypeName> param : method.getParameters()) {
				methodBuilder.addJavadoc("@param $L", param.value0);
				methodBuilder.addJavadoc("\n\tis mapped to parameter <strong>$L</strong>\n",
						method.findParameterAliasByName(param.value0));
			}

			InsertRawHelper.generateJavaDocReturnType(methodBuilder, returnType);
		}
	}
299497
@Validate
    public void start() {
        try {
            Map<String, Object> map = new HashMap<>();
            for (Persistence.PersistenceUnit.Properties.Property p :
                    persistenceUnitXml.getProperties().getProperty()) {
                map.put(p.getName(), p.getValue());
            }

            if (isOpenJPA()) {
                map.put("openjpa.ManagedRuntime",
                        "invocation(TransactionManagerMethod=org.wisdom.framework.jpa.accessor" +
                                ".TransactionManagerAccessor.get)");
            }

            // This is not going to work with OpenJPA because the current version of OpenJPA requires an old version
            // of javax.validation. The wisdom one is too recent.
            map.put("javax.persistence.validation.factory", validator);

            Dictionary<String, Object> properties = new Hashtable<>();
            properties.put(UNIT_NAME_PROP, persistenceUnitXml.getName());
            properties.put(UNIT_VERSION_PROP, sourceBundle.bundle.getVersion());
            properties.put(UNIT_PROVIDER_PROP, provider.getClass().getName());
            List<String> entities = persistenceUnitXml.getClazz();
            properties.put(UNIT_ENTITIES_PROP, entities.toArray(new String[entities.size()]));
            properties.put(UNIT_TRANSACTION_PROP, getTransactionType().toString());

            // If the unit set the transaction to RESOURCE_LOCAL, no JTA involved.
            if (persistenceUnitXml.getTransactionType() ==
                    org.wisdom.framework.jpa.model.PersistenceUnitTransactionType.RESOURCE_LOCAL) {
                entityManagerFactory = provider.createContainerEntityManagerFactory(this, map);

                entityManager = entityManagerFactory.createEntityManager();

                emfRegistration = bundleContext.registerService(EntityManagerFactory.class, entityManagerFactory, properties);
                emRegistration = bundleContext.registerService(EntityManager.class,
                        entityManager, properties);

                repository = new JPARepository(persistenceUnitXml, entityManager,
                        entityManagerFactory, transactionManager, sourceBundle.bundle.getBundleContext());
            } else {
                // JTA
                entityManagerFactory = provider.createContainerEntityManagerFactory(this, map);
                entityManager = new TransactionalEntityManager(transactionManager, entityManagerFactory, this);

                emRegistration = bundleContext.registerService(EntityManager.class,
                        entityManager, properties);
                emfRegistration = bundleContext.registerService(EntityManagerFactory.class, entityManagerFactory, properties);
                repository = new JPARepository(persistenceUnitXml, entityManager,
                        entityManagerFactory, transactionManager, sourceBundle.bundle.getBundleContext());
            }
        } catch (Exception e) {
            LOGGER.error("Error while initializing the JPA services for unit {}",
                    persistenceUnitXml.getName(), e);
        }

    }