NHibernate "Repeated column in mapping for collection" exception - exception

Consider the following NHibernate mapping, and notice the commented properties. These are the same columns as the key and index column specified in the map. When I remove the comments (thus including the TypeOfPart and UnitId columns for the properties) I get the "Repeated column in mapping for collection" exception.
<map name="Parts" table="ActiveUnitParts" lazy="false">
<key column="UnitId" />
<index column="TypeOfPart" type="integer"/>
<composite-element class="ActiveUnitPart">
<property name="Id" />
<property name="CreationDate" />
<property name="PartInfo"/>
<property name="Remarks"/>
<!-- <property name="TypeOfPart" /> -->
<!-- <property name="UnitId" /> -->
</composite-element>
</map>
What I need in code is a Dictinonary<TypeOfpart, ActiveUnitPart>. But the problem I have is that the values for the properties UnitId and TypeOfPart aren't set in the ActiveUnitPart instance in the Dictinonary<TypeOfpart, ActiveUnitPart>.
Yes, the list of related parts of this unit is loaded, and yes the key in the dictionary is related to the right part. But I do not understand why I can not reference the TypeOfPart and UnitId to fill the properties in ActiveUnitPart itself as well.
How can I solve or workaround this?
Motivation of why I need this:
I must be able to work with ActiveUnitParts without referencing the related Unit (UnitId)
EDIT 1:
I know I can intercept the setter of the Parts property of the Unit and iterate through the Dictinonary<TypeOfpart, ActiveUnitPart> to set the values in code, but it seems like a hack and I wish to learn a more elegant NHibernate way of getting it done, if possible.

It is possible, just change the mapping from column to formula. The best way how to achieve that would be:
<property name="TypeOfPart" formula="TypeOfPart" insert="false" update="false" />
<property name="UnitId" formula="UnitId" insert="false" update="false" />

Related

Magento 2 custom module admin grid item duplicate

I try to create custom admin grid. When I search for information It can be searched But after I cancel the search The result is a duplicate of every item.
it is resolve a problem
<dataSource name="modulename_logger_index_listing_data_source" component="Magento_Ui/js/grid/provider">
<settings>
<storageConfig>
<param name="cacheRequests" xsi:type="boolean">false</param>
</storageConfig>
<updateUrl path="mui/index/render"/>
</settings>
<dataProvider class="Company\ModuleName\UI\DataProvider\Logger\DataProvider"
name="modulename_logger_index_listing_data_source">
<settings>
<requestFieldName>waitingtask_id</requestFieldName>
<primaryFieldName>waitingtask_id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>

How to include biml file when it has more than one root node?

I have a biml file and want to use the include directive to bring in biml from another file that can get reused in other places, but it keeps giving this error when I do Check for Errors with BIDSHelper:
There are multiple root elements
I see examples online of people using the include directive but no mention on this problem. I can't find any valid element to wrap my biml in, it has to be this chunk.
ErrorHandling.biml:
<UnionAll Name="Union Errors">
<InputPaths>
<InputPath OutputPathName="Lookup Site.Error" />
<InputPath OutputPathName="Detail Level Source.Error" />
<InputPath OutputPathName="Site to Integer.Error" />
</InputPaths>
</UnionAll>
<DerivedColumns Name="Error Metadata">
<InputPath OutputPathName="Union Errors.Output" />
<Columns>
<Column Name="execution_guid" DataType="AnsiString" Length="50" CodePage="1252">(DT_STR,50,1252)#[User::ExecutionGUID]</Column>
<Column Name="error_time" DataType="DateTime" >GETDATE()</Column>
<Column Name="PackageID" DataType="AnsiString" Length="38" CodePage="1252">(DT_STR,38,1252)#[System::PackageID]</Column>
<Column Name="DataflowID" DataType="AnsiString" Length="38" CodePage="1252">(DT_STR,38,1252)#[System::TaskID]</Column>
<Column Name="Step_Name" DataType="AnsiString" Length="50" CodePage="1252">(DT_STR,50,1252)"QI Load"</Column>
<Column Name="Task_Name" DataType="AnsiString" Length="50" CodePage="1252">(DT_STR,50,1252)"Detail Level Check"</Column>
</Columns>
</DerivedColumns>
Master.biml snippet:
<RowCount Name="Row Count" VariableName="User.CheckRowCount">
<InputPath OutputPathName="Lookup Site.Match" />
</RowCount>
<## include file="ErrorHandling.biml" #>
</Transformations>
I found two ways to get this to work- either change the extension of the file to something like .txt or simply don't select it when you "compile" your files with BIDSHelper and do "Check BIML for Errors" or "Generate SSIS packages". Just select the main files that use any included files and contain proper XML.

Work Item HTMLFieldControl Content

I am trying to pre-populate some a few different objects in a User Story in my TFS2012 work items list. The HTMLFieldControl is can be found in the Work Item Types section and I can see that it's created here:
<Tab Label="Details">
<Control FieldName="System.Description" Type="HtmlFieldControl" Dock="Fill" />
</Tab>
I've been looking on Google but I just can't seem to find anything around adding text into this field so that it is always available, perhaps I'm just doing something wrong.
Would doing something similar to this give me the results I require? I can't really just try it and potentially break the system (which is unfortunate) so I need some guidance so that I could quickly fix any formatting / spelling without having to roll back any changes.
<Tab Label="Details">
<Control FieldName="System.Description" Type="HtmlFieldControl" Dock="Fill" >
<FIELD name="Description" refname="System.Description" type="Text" Content="Hello there"/>
</Control>
</Tab>
Obviously the above is purely made up (from the FIELD section) but I included here just along the lines of what I was thinking and hopefully to show what I'm trying to do.
You were looking in the wrong place; those are the definitions for the form (aka, how the Work Item is displayed graphically). You need to scroll up to the top, under FIELDS, and find this:
<FIELD name="Description" refname="System.Description" type="HTML" />
...then change it to this:
<FIELD name="Description" refname="System.Description" type="HTML">
<DEFAULT from="value" value="Hello there" />
</FIELD>

MSDeploy SetParameters.xml create empty value

So my question is relatively simple.
In my Parameters.xml file I have the following line:
<parameter name="SEND_TO_FRIEND_BCC" description="Email address of developer" defaultValue="" tags="">
<parameterEntry kind="XmlFile" scope"\\web.config$" match="/configuration/appsettings/add[#key='SEND_TO_FRIEND_BCC']/#value" />
</parameter>
When publish this is creating a file that ends up like this:
<setParameter value="" name="SEND_TO_FRIEND_BCC" />
When going live, this should replace the current web.config value for SEND_TO_FRIEND_BCC to an empty string. Instead, when I try an publish I get the following:
Error: The 'SEND_TO_FRIEND_BCC" argument cannot be null or empty.
Error count: 1.
at InRelease.MSDeploy.Program.Main(String[] args)
Have to tell MSDeploy that it is okay for the value to be empty ...
<parameter name="SEND_TO_FRIEND_BCC" description="Email address of developer" defaultValue="" tags="">
<parameterValidation kind="AllowEmpty" />
<parameterEntry kind="XmlFile" scope"\\web.config$" match="/configuration/appsettings/add[#key='SEND_TO_FRIEND_BCC']/#value" />
</parameter>
So, by pure chance I tried entering a single empty space and it worked.
If there is a better way I am still eager to learn more...

Struts2 grid json

How can I exclude Hibernate objects that are listed as FetchType.LAZY? It causes problems because I get a org.hibernate.LazyInitializationException. I understand that it is trying to serialize the object and it can not because the session is closed. How can I disable it? I have many objects that do this and it would not be feasible to make them eager nor to remove them as there are too many of them. Please help.
I was able to use includeProperties as suggested by nmc, however it would still be nice to not have to define the properties and see if JSONUtil can just ignore lazy loaded objects.
<result name="success" type="json">
<param name="includeProperties"> ^gridModel\[\d+\]\.first, ^gridModel\[\d+\]\.last, rows, page, total, record</param>
</result>
In your struts.xml:
<result name="success" type="json">
<param name="excludeProperties">
<!-- insert comma separated parameters to be excluded here -->
</param>
</result>
Or you can also do an includeProperties. See http://struts.apache.org/2.2.3/docs/json-plugin.html for more details.