Changing double to Double in hybris - java

I have a requirement to change a field from double to Double in hybris typeSystem and was wondering if it actually creates a new database field or just changes the type in app layer.
Thanks in advance.

After the items.xml change and system update the data base field remained the same type. All reads and write are from the same column. So, the answer to my question is no, the column type does not change in database. Only the application layer (model) has changed the field from double to Double.

You have the mapping in core-advanced-deployment.xml.
The mapping depends on DB :
<type-mapping type="java.lang.Double" persistence-type="decimal(30,8)" />
<type-mapping type="double" persistence-type="decimal(30,8) DEFAULT 0" />
or:
<type-mapping type="java.lang.Double" persistence-type="double" />
<type-mapping type="double" persistence-type="double default 0" />
or:
<type-mapping type="java.lang.Double" persistence-type="float" />
<type-mapping type="double" persistence-type="float default 0" />
So you see that it's currently map that's why you can do that and you don't see change in the DB.
Note that changing a type is strongly discouraged because you can switch to uncompatble type. For instance if you have a column of String you can't migrate it to Number for example because a string is not always parseable in a number.

Related

Mybatis2 to MyBatis3 Conversion - Results with Same Property

I am working on converting a large MyBatis2 map to a MyBatis3 map, and have run into a bit of an issue where I have a resultMap with multiple result elements using the same property attribute (and the class is generated from a WSDL outside of my control):
<resultMap id="blah" class="someWsdlGeneratedClass">
<result property="addressLine"
resultMap="addressLineOneListMap"
javaType="java.util.List" />
<result property="addressLine"
resultMap="addressLineTwoListMap"
javaType="java.util.List" />
</resultMap>
<resultMap id="addressLineXListMap" class="string">
<!-- Result maps are the same except for column -->
<result property="addressLine" column="COLUMN_X" />
</resultMap>
Notice that both properties are "addressLine".
This works fine for Mybatis2. However, if I try to use the same pattern for MyBatis3, I get an IllegalArgumentException: Result Maps collection already contains value for Mapper.mapper_resultMap[blah]_collection[addressLine]
<resultMap id="blah" type="someWsdlGeneratedClass">
<collection property="addressLine"
resultMap="addressLineOneListMap"
javaType="java.util.List" />
<collection property="addressLine"
resultMap="addressLineTwoListMap"
javaType="java.util.List" />
</resultMap>
I'd like to avoid writing a wrapper around the generated class in a Dto object, if possible, as that would result in a major refactoring effort in the project. Is there something I can add in the map itself?
You can add a 2nd setter (setAddressLine2) to your generated dto.
In which your code for it can just add to addressLine. ex:
void setAddressLine2(final List<Address> addressLine2) {
address.addAll(addressLine2);
}
If that's not possible you can try changing your query to return a union of the 2 columns
Without knowing your exact query it would look something like:
SELECT foo, addressLine1 as Address
FROM bar
UNION
SELECT foo, addressLine2 as Address
FROM bar
If that isn't possible then you need to create a test project and create an issue on https://github.com/mybatis/mybatis-3 and request a feature.
That option is probably best anyways as I'm not sure you are using it correctly. It seems that your 2nd example (using collection) is correct (conceptually at least. you still can't map to the same property using it) but the first won't behave as you explained it?

How to add a LIST item with Java API Repository in Oracle ATG?

I create this repository:
<gsa-template>
<item-descriptor name="indirizzo" >
<table name="INDIRIZZO" type="primary" id-column-name="ID_INDIRIZZO">
<property name="via" data-type="string" column-name="VIA" />
<property name="civico" data-type="int" column-name="CIVICO" />
</table>
</item-descriptor>
<item-descriptor name="utente" >
<table name="UTENTE" type="primary" id-column-name="ID_UTENTE">
<property name="nome" data-type="string" column-name="NOME" />
<property name="cognome" data-type="string" column-name="COGNOME" />
<property name="indirizzi" data-type="list" component-item-type="indirizzo" />
</table>
</item-descriptor>
In the Java class I want to add a new user with a multiple address. Then I want to use the Java API repository. I tried this:
MutableRepositoryItem item_utente = getMutableRepository().createItem(
UTENTE);
MutableRepositoryItem item_indirizzo = getMutableRepository().createItem(
INDIRIZZO);
item_indirizzo.setPropertyValue(VIA, v1);
item_indirizzo.setPropertyValue(CIVICO, civ1);
getMutableRepository().addItem(item_indirizzo);
item_indirizzo.setPropertyValue(VIA, v2);
item_indirizzo.setPropertyValue(CIVICO, civ2);
getMutableRepository().addItem(item_indirizzo);
item_utente.setPropertyValue(NOME, n);
item_utente.setPropertyValue(COGNOME, c);
item_utente.setPropertyValue(INDIRIZZI, item_indirizzo);
getMutableRepository().addItem(item_utente);
but it does not work, I SUPPOSE because I did not create an actual java list.
I want to insert in my DB an user with respective 2 or more addresses.
Some different idea or do I fix my code?
If your datatype is list, you can add items using an xml just like you do for primitive data types with comma separated values as below:
<add-item item-descriptor="utente" id="test1">
<set-property name="nome" value="testNome"/>
<set-property name="cognome" value="testCognome"/>
<set-property name="indirizzi" value="test2,test3,test4"/>
</add-tem>
Take look at below page for more details.
http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGRepositoryGuide/html/s1302setproperty01.html
create the List of Repository item .
List<RepositoryItem> item_indirizzo_List=new ArrayList<RepositoryItem>();
add item to the list. And then add like below
item_utente.setPropertyValue(INDIRIZZI, item_indirizzo_List);
May be this will help you.

Mule db component Input payload from another db query

I need a basic Mule flow in order to select rows from one database, transform the payload and call a procedure in another database. I don't want to use DataMapper component, I would like to use Java Transformer instead.
My XML flow:
<set-variable variableName="currentOrder" value="#[payload.increment_id]" doc:name="Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="GET ORDER">
<db:parameterized-query><![CDATA[select id from sales where id=#[currentOrder]]]></db:parameterized-query>
</db:select>
<custom-transformer class="com.mycompany.transformers.TargerProc" doc:name="Java"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="PROC1">
<db:parameterized-query><![CDATA[call proc1(:P1,:P2)]]></db:parameterized-query>
<db:in-param name="P1" type="NUMERIC" value="#[payload.id]"/>
<db:out-param name="P2" type="NUMERIC" value=""/>
</db:stored-procedure>
First problem:
Message payload is of type: CaseInsensitiveHashMap
Could someone shed some light on this? I think it is really simple to achieve this.
Thanks in advance!
Try this <db:parameterized-query>{ call proc1(:P1,:P2) }</db:parameterized-query> :-
<set-variable variableName="currentOrder" value="#[payload.increment_id]" doc:name="Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="GET ORDER">
<db:parameterized-query><![CDATA[select id from sales where id=#[currentOrder]]]></db:parameterized-query>
</db:select>
<custom-transformer class="com.mycompany.transformers.TargerProc" doc:name="Java"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="PROC1">
<db:parameterized-query>{ call proc1(:P1,:P2) }</db:parameterized-query>
<db:in-param name="P1" type="NUMERIC" value="#[payload.id]"/>
<db:out-param name="P2" type="NUMERIC" value=""/>
</db:stored-procedure>

Solr query only returns Id's

I have wanting to import data from a table and index it using solr..
I am using solr-tomcat admin panel.
But whenever I query it returns to me only the id's and value.
I have also tried adding FIELDS to fl , but that also does not help.
here is my data-config.xml file:
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/{DB_NAME}"
user="{DB_USER}"
password="{DB_PASSS}"
/>
<document>
<entity name="id" query="select s3_location,file_name from video">
<field column="s3_location" name="s3_location"/>
<field column="file_name" name="file_name"/>
</entity>
</document>
</dataConfig>
Is there any way to get the above s3_location and file_name fields also.
You need to specify the actual field names in the fl parameter or use * to indicate all fields. Also, please note that the fields must have been defined with stored=true in your schema.xml file for them to be returned/visible during a query.
fl=id,s3_location,file_name
fl=*
Are you sure you are importing the data at all? If you start with empty index, do you get anything?
The reason I ask is because you are not mapping the id field explicitly. Now, I believe there is implicit mapping of the fields by Jdbc data source based on names, but relying on it is risky when you are just starting.
Otherwise, like Paige said, make sure you defined those fields in your schema and that they are actually stored.

Struts 1: How to set <html:multibox /> value using form bean?

I would like to have the value of my multibox to be set dynamically from the form. I'm using a <display:table /> tag to show a list in my form in a table however, I have checboxes on every row on the table which I would like the value and disabled attributes set depending on the object in the list that corresponds with that row in the table. This is what I'm currently doing.
<display:table name="sessionScope.SearchForm.companyDevices" requestURI="my/action.jspa">
<display:column>
<html:multibox property="selectedDevices"
value="${macAddress}" <!-- HERE -->
disabled="${isAssigned}"/> <!-- AND HERE -->
</display:column>
<display:column property="macAddress" title="Mac Address" />
<display:column property="vendor" title="Vendor"/>
<display:column property="model" title="Model"/>
<display:column property="deviceStatus" title="Device Status" />
</display:table>
As you can see a column property uses the same macAddress bean value and it displays the macAddress there successfully, however in the multibox it doesn't set the value to the macAddress for some reason. Same goes for the disabled attribute.
I can't seem to identify what is wrong. How do I set dynamic values for multiboxes in a display:table?
I figured out a way. I replaced the multibox tag above with
<display:table name="sessionScope.SearchForm.companyDevices" requestURI="my/action.jspa" id="device"> <!-- ID ATTRIBUTE ADDED -->
<html:multibox property="selectedDevices"><bean:write name="searchForm" property="companyDevices[${row_rowNum - 1}].macAddress" /></html:multibox>
rowNum is an implicitly created variable in struts and to retrieve the row Number for a particular row. To identify a row an Id needs to be assigned. By setting the id to 'device' in the display:table I use device_rowNum (the implicitly created variable from the combination of my the id attribute and rowNum) get a row's particular number which is associated with its position in the list to be able to retrieve the value that I want.

Categories