Returns the entity with the required fields for an insert set.

@return
173882
public HousingComplexUnit instantiateForInsert() {
		HousingComplexUnit entity = new HousingComplexUnit();
		entity.setIsDeleted(Boolean.FALSE);
		return entity;
    }
1168818
public static CmsEntity getEntity() {

        if ((INSTANCE == null) || (INSTANCE.m_entityObserver == null)) {
            CmsDebugLog.getInstance().printLine("handling external registration");
            if (isObserverExported()) {
                return CmsEntityBackend.createFromNativeWrapper(nativeGetEntity());
            } else {
                throw new RuntimeException("Editor is not initialized yet.");
            }
        } else {
            return INSTANCE.getCurrentEntity();
        }
    }
748884
public Table<Entity<T>> getOrCreateTable()
   {
      Node node = childNode.getOrCreate("table");
      Table<Entity<T>> table = new TableImpl<Entity<T>>(this, "table", childNode, node);
      return table;
   }
505206
protected function _getSelect() {
        $fields = $this->_entity->fields();

        switch ($this->_type) {
            case self::QUERY_SELECT :
                $this->_query .= 'SELECT ';

                $nFields = count($fields);
                $i = 0;

                //We add all fields to the select
                foreach ($fields as $value) {
                    //We mustn't add fields which don't exist in the SQL table
                    if ($value->foreign == null || in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                        $this->_query .= $this->_entity->name() . '.' . $value->name . ' AS ' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }
                    //To optimize the relation ONE TO MANY, we replace the join value by the number of element in this join
                    else if ($value->foreign != null && $value->foreign->type() == ForeignKey::ONE_TO_MANY) {
                        $currentEntity = $value->foreign->entity();
                        $currentField = $value->foreign->field();
                        $referenceEntity = $value->foreign->referenceEntity();
                        $referenceField = $value->foreign->referenceField();

                        $this->_query .= '(SELECT COUNT(*) FROM ' . $referenceEntity . ' WHERE ' . $referenceEntity . '.' . $referenceField . ' = ' . $currentEntity . '.' . $currentField . ') AS count_one_' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }
                    //To optimize the relation MANY TO MANY, we replace the join value by the number of element in this join
                    else if ($value->foreign != null && $value->foreign->type() == ForeignKey::MANY_TO_MANY) {
                        $currentEntity = $value->foreign->entity();
                        $currentField = $this->_entity->primary();
                        $referenceEntity = $value->foreign->referenceEntity();
                        $referenceField = $value->foreign->referenceField();
                        $current = strtolower($currentEntity . $currentField);
                        $reference = strtolower($referenceEntity . $referenceField);
                        $table = [$current, $reference];
                        sort($table, SORT_STRING);
                        $table = ucfirst($table[0] . $table[1]);

                        $this->_query .= '(SELECT COUNT(*) FROM ' . $table . ' WHERE ' . $table . '.' . $currentEntity . '_' . $currentField . ' = ' . $currentEntity . '.' . $currentField . ') AS count_many_' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }

                    $i++;
                }

                $this->_query = preg_replace('#^(.*)(, )$#isU', '$1', $this->_query);

                //if some fields have a relation one to one or many to one, we had a join
                foreach ($fields as $value) {
                    if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                        $this->_query .= ', ';

                        $class = $this->_getTableEntity($value->foreign->referenceEntity());

                        $fieldsRelation = $class->fields();
                        $nFieldsRelation = count($fieldsRelation);
                        $i = 0;

                        foreach ($fieldsRelation as $relation) {
                            if ($relation->foreign == null || in_array($relation->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                                $this->_query .= $value->name . '_' . $class->name() . '.' . $relation->name . ' AS ' . $value->name . '_' . $class->name() . '_' . $relation->name;

                                if ($i < $nFieldsRelation - 1) {
                                    $this->_query .= ', ';
                                }
                            }

                            $i++;
                        }

                        $this->_query = preg_replace('#^(.*)(, )$#isU', '$1', $this->_query);
                    }
                }
                break;

            case self::QUERY_DISTINCT :
                $primaryColumn = $this->_entity->name() . '.' . $this->_entity->fields()[$this->_entity->primary()]->name;

                if (preg_match('(' . $primaryColumn . ')', $this->_distinct)) {
                    $this->_query .= 'SELECT DISTINCT ' . $this->_distinct . ' ';
                }
                else {
                    $this->_query .= 'SELECT DISTINCT ' . $this->_distinct . ', ' . $primaryColumn . ' ';
                }
                break;

            case self::QUERY_COUNT :
                $this->_query .= 'SELECT COUNT(*) ';
                break;
        }

        $this->_query .= ' FROM ' . $this->_entity->name();

        /** If there are relations like one to one, many to one or many to many */
        foreach ($fields as $value) {
            if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                $entity = $value->foreign->entity();
                $field = $value->foreign->field();
                $referenceEntity = $value->foreign->referenceEntity();
                $referenceField = $value->foreign->referenceField();
                $this->join($value->foreign->join(), $referenceEntity, $entity . '.' . $field . ' = ' . $field . '_' . $referenceEntity . '.' . $referenceField, $field);
            }
            else if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::MANY_TO_MANY])) {
                //We add here two join (relation table and table linked)
                $currentEntity = $value->foreign->entity();
                $currentField = $this->_entity->primary();
                $referenceEntity = $value->foreign->referenceEntity();
                $referenceField = $value->foreign->referenceField();

                $current = strtolower($currentEntity . $currentField);
                $reference = strtolower($referenceEntity . $referenceField);
                $table = [$current, $reference];
                sort($table, SORT_STRING);
                $table = ucfirst($table[0] . $table[1]);

                $this->join($value->foreign->join(), $table, $table . '.' . $this->_entity->name() . '_' . $currentField . ' = ' . $this->_entity->name() . '.' . $currentField);
                $this->join($value->foreign->join(), $value->foreign->referenceEntity(), $table . '.' . $referenceEntity . '_' . $referenceField . ' = ' . $referenceEntity . '.' . $referenceField);
            }
        }
    }
462998
protected Object getObjectFromResultSet() throws PersistenceBrokerException
    {

        try
        {
            // if all primitive attributes of the object are contained in the ResultSet
            // the fast direct mapping can be used
            return super.getObjectFromResultSet();
        }
                // if the full loading failed we assume that at least PK attributes are contained
                // in the ResultSet and perform a slower Identity based loading...
                // This may of course also fail and can throw another PersistenceBrokerException
        catch (PersistenceBrokerException e)
        {
            Identity oid = getIdentityFromResultSet();
            return getBroker().getObjectByIdentity(oid);
        }

    }
1097401
private function insert() {
        if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this);

        // pre-processing hook
        if ($this->beforeInsert() !== true)
            return $this;

        $mapping = $this->dao()->getMapping();

        // collect column values
        $values = [];
        foreach ($mapping['columns'] as $column => $property) {
            $values[$column] = $this->getPhysicalValue($column);
        };

        // perform insertion
        $id = $this->doInsert($values);
        $this->_modified = false;

        // assign the returned identity value
        $idName = $mapping['identity']['name'];
        if ($this->$idName === null)
            $this->$idName = $id;

        // post-processing hook
        $this->afterInsert();
        return $this;
    }
761909
public Entity<EntityMappings<T>> getOrCreateEntity()
   {
      List<Node> nodeList = childNode.get("entity");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new EntityImpl<EntityMappings<T>>(this, "entity", childNode, nodeList.get(0));
      }
      return createEntity();
   }
503484
@ManyToOne(targetEntity = org.openprovenance.prov.sql.QualifiedName.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "ENTITY")
    public org.openprovenance.prov.model.QualifiedName getEntity() {
        return entity;
    }
989528
public String getCreateTableSQL() {
		StringBuilder builder = new StringBuilder();
		// Add columns
		for (Column column : getColumns()) {
			addColumn(builder, column);
			builder.append(", ");
		}
		// Add references
		StringBuilder referencesBuilder = new StringBuilder();
		for (Column column : getColumns()) {
			if (column.getReference() != null) {
				referencesBuilder.append("FOREIGN KEY(").append(column.getColumnName()).append(") REFERENCES ").append(
					column.getReference().getTableName()).append("(").append(
					column.getReference().getColumn().getColumnName()).append(") ON DELETE CASCADE, ");
			}
		}
		// Add unique constraint
		StringBuilder uniqueBuilder = new StringBuilder();
		boolean first = true;
		for (Column column : getColumns()) {
			if (column.isUnique()) {
				if (!first) {
					uniqueBuilder.append(", ");
				}
				first = false;
				uniqueBuilder.append(column.getColumnName());
			}
		}
		return getCreateTableSQL(builder.toString(), referencesBuilder.toString(), uniqueBuilder.toString());
	}
1149783
public PartialResponseInsertType<PartialResponseChangesType<T>> getOrCreateInsert()
   {
      List<Node> nodeList = childNode.get("insert");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new PartialResponseInsertTypeImpl<PartialResponseChangesType<T>>(this, "insert", childNode, nodeList.get(0));
      }
      return createInsert();
   }
357209
public Candidate instantiateForInsert() {
		Candidate entity = new Candidate();
		entity.setCategory(new Category(512973));
		entity.setComments("New lead candidate");
		entity.setEmployeeType("W2");
		entity.setIsDeleted(Boolean.FALSE);
		entity.setIsEditable(Boolean.TRUE);
		entity.setPreferredContact("Email");
		entity.setStatus("New Lead");
		entity.setOwner(new CorporateUser(1));
		entity.setName("");
		entity.setFirstName("");
		entity.setLastName("");
		entity.setUsername(new DateTime().toString());
		entity.setPassword("secret");
		return entity;
	}
985018
public String getInsertDollarPrepareSQL(T bean) {
        if (this.tableStrategy == null) return insertDollarPrepareSQL;
        return insertDollarPrepareSQL.replace("${newtable}", getTable(bean));
    }
769782
def insert(self):
        """"""
        self.default_val = 0
        #fields = self.fields
        #fields = self.orm_class.depart(self.fields, is_update=False)
        #self.set_fields(fields)
        return self.interface.insert(
            self.schema,
            self.fields
        )

        return self.interface.insert(self.schema, self.fields)
566544
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.ALL} )
    @JoinColumn(name="REQUIREMENT_ID")
    public Requirement getRequirement()
    {
        return requirement;
    }
1224536
public List<Entity<EntityMappings<T>>> getAllEntity()
   {
      List<Entity<EntityMappings<T>>> list = new ArrayList<Entity<EntityMappings<T>>>();
      List<Node> nodeList = childNode.get("entity");
      for(Node node: nodeList)
      {
         Entity<EntityMappings<T>>  type = new EntityImpl<EntityMappings<T>>(this, "entity", childNode, node);
         list.add(type);
      }
      return list;
   }
1008313
public CandidateReference instantiateForInsert() {
		CandidateReference entity = new CandidateReference();
		entity.setIsDeleted(Boolean.FALSE);
		entity.setCandidate(new Candidate(1));
		return entity;
	}
920241
public static final String[] getRequiredSolrFields() {

        if (null == m_requiredSolrFields) {
            List<Locale> locales = OpenCms.getLocaleManager().getAvailableLocales();
            m_requiredSolrFields = new String[14 + (locales.size() * 6)];
            int count = 0;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_PATH;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_TYPE;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_CREATED;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_LASTMODIFIED;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_EXPIRED;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_RELEASED;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_SIZE;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_STATE;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_USER_CREATED;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_ID;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_USER_LAST_MODIFIED;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_ADDITIONAL_INFO;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_CONTAINER_TYPES;
            m_requiredSolrFields[count++] = CmsSearchField.FIELD_RESOURCE_LOCALES;
            for (Locale locale : locales) {
                m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName(
                    CmsSearchField.FIELD_TITLE_UNSTORED,
                    locale.toString()) + "_s";
                m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName(
                    CmsPropertyDefinition.PROPERTY_TITLE,
                    locale.toString()) + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT + "_s";
                m_requiredSolrFields[count++] = CmsPropertyDefinition.PROPERTY_TITLE
                    + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT
                    + "_s";
                m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName(
                    CmsSearchField.FIELD_DESCRIPTION,
                    locale.toString()) + "_s";
                m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName(
                    CmsPropertyDefinition.PROPERTY_DESCRIPTION,
                    locale.toString()) + CmsSearchField.FIELD_DYNAMIC_PROPERTIES + "_s";
                m_requiredSolrFields[count++] = CmsPropertyDefinition.PROPERTY_DESCRIPTION
                    + CmsSearchField.FIELD_DYNAMIC_PROPERTIES
                    + "_s";
            }
        }
        return m_requiredSolrFields;
    }