on 2018 Jun 12 3:48 PM
Hi, I have been trying to create a simple relation between two entities "Car" and "Engine". So, due to One-to-One it's not a relation. Here is my items:
<itemtypes>
<itemtype code="Car" extends="GenericItem" autocreate="true" generate="true">
<deployment table="Car" typecode="10111"/>
<attributes>
<attribute qualifier="engine" type="Engine">
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="Engine" extends="GenericItem" autocreate="true" generate="true">
<deployment table="Engine" typecode="10112"/>
<attributes>
<attribute qualifier="power" type="java.lang.Integer">
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
</itemtypes>
Here is my wrong impex file.
INSERT Car; name[unique=true]; &engineid;
; Bentley; engineuid
; Lada; engineuid
; Zaporojec; engineuid
INSERT Engine; name[unique=true]; power; pk[unique = true]
; Hemi; 1500; engineuid
; Chevrolet; 600; engineuid
; Nuclear; 1000000; engineuid
How it should looks like to import new data for created itemtypes above? Thanks in advance!
Request clarification before answering.
Thanx guys, it works!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This code is works for me.
Changes for itemtypes. So, if itemtype extends from GenericType new uid filed should be created.
<itemtypes>
<itemtype code="Car" extends="GenericItem" autocreate="true" generate="true">
<deployment table="Car" typecode="10111"/>
<attributes>
<attribute qualifier="name" type="java.lang.String">
<persistence type="property"/>
<modifiers read="true" initial="true" write="true" search="true" optional="false"/>
</attribute>
<attribute qualifier="engine" type="Engine">
<persistence type="property"/>
</attribute>
<attribute qualifier="uid" autocreate="true" type="java.lang.String" generate="true">
<persistence type="property"/>
<modifiers read="true" initial="true" write="false" search="true" optional="false" unique="true"/>
</attribute>
</attributes>
<indexes>
<index name="UID" unique="true">
<key attribute="uid"/>
</index>
</indexes>
</itemtype>
<itemtype code="Engine" extends="GenericItem" autocreate="true" generate="true">
<deployment table="Engine" typecode="10112"/>
<attributes>
<attribute qualifier="power" type="java.lang.Integer">
<persistence type="property"/>
</attribute>
<attribute qualifier="uid" autocreate="true" type="java.lang.String" generate="true">
<persistence type="property"/>
<modifiers read="true" initial="true" write="false" search="true" optional="false" unique="true"/>
</attribute>
</attributes>
<indexes>
<index name="UID" unique="true">
<key attribute="uid"/>
</index>
</indexes>
</itemtype>
</itemtypes>
Before run script Hybris required update for persistance: Impex script for update:
INSERT Engine; uid[unique=true]; name; power;
; hemi; Hemi; 1500
; chevrolet; Chevrolet; 600
; nuclear; Nuclear; 1000000
INSERT Car; uid[unique = true]; name; engine(uid)
; bentley; Bentley; hemi
; lada; Lada; chevrolet
; zaporozhetz;Zaporojec; nuclear
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, you seem to be missing name property that is not unique. And you are trying to set a PK value that you should not do . Instead you should add a UID or ID property that is of type String . Then your import could look something like:
INSERT_UPDATE Engine;UID[unique=true];power ;Hemi;1500 ;Chevorlet;600 ; Nuclear; 1000000 INSERT_UPDATE Car;UID[unique=true];engine(uid[unique=true]) ; Bentley;Hemi ; Lada; Chevrolet ; Zaporojec; Nuclear
You should never set the pk value because hybris takes care of it. But you might use PK values to reference unique items in the impex.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.