Skip to Content


This document describes how to work with tuple in MDM.

A tuple is a hierarchical structure in MDM. It can’t exist by itself, it has a parent table/tuple. It can be a nested structure with one to many relation at every level. e.g A vendor can have multiple contact information.

So contact information (address, phone number, etc) can be grouped under a tuple which will be part of vendor table.

For modifying/creating tuple data, you need to first get the parent record in main table which holds the tuple.

Creating new record with Tuple:

Folllowing is the sample code to create new record in mdm with multiple tuplevalues.

TupleDefinitionId definitionId = reposSchema.getTupleDefinition(tupleName).getId();  
TupleDefinitionSchema tupleDefinitionSchema = reposSchema.getTupleDefinitionSchema(definitionId);  
FieldProperties[]  tupleFieldProps=tupleDefinitionSchema.getFields();  
CreateRecordsCommand createRecordsCommand=new CreateRecordsCommand(userCtx);  
//Create one array of record instance with the number of records you want to insert in MDM table  
Record[]records = new Record[collection.size()];  
//loop on your input collection and call following method to set tuple values for each record  
Record record = RecordFactory.createEmptyRecord(tableId);  
MultiTupleValue multiTupleValue = new MultiTupleValue();  
TupleValue tupleVal= MdmValueFactory.createTupleValue();  
//Now loop on your tuple value set and get value for each field in tuple  
//set it into the tuplevalue instance  
for(int k=0;k<tupleFieldProps.length;k++)  
      String tupleFieldName=tupleFieldProps[k].getCode();  
// here we have the new values stored in one object.
      String tupleValue = obj.getFieldValue(tupleFieldName);  
            String fieldType =tupleFieldProps[k].getTypeName().toString();        
if (fieldType.equals("Text"))   
      .getId(), new StringValue(tupleValue));  
elseif (fieldType.equals("Real"))   
             FloatValue fValue = new FloatValue(Float  
                                         .getId(), fValue);  
elseif (fieldType.equals("Integer")) {  
           IntegerValue intvalue = new     IntegerValue(Integer.parseInt(tupleValue));  
           tupleVal.setFieldValue(tupleFieldProps[k].getId(), intvalue);  
  elseif (fieldType.equals("Lookup [Flat]")) {  
                                .getId(), new LookupValue(new RecordId(  
  elseif(((tupleFieldProps[k].getTypeName()).toString()).equals("Literal Date")){  
           try {  
                SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");   
                String effectiveDate = tupleValue;  
                Calendar cal=Calendar.getInstance();  
                tupleVal.setFieldValue(tupleFieldProps[k].getId(), new DateTimeValue(cal));  
catch (Exception e)   
//Add Tuple value to the multiple tuple value instance  
//End of loop for tuple value set  
//Now set multiple tuple value instance to the tuple field of the record  
     record.setFieldValue(tableSchema.getFieldId(tupleName), multiTupleValue);  
//End of loop for main table collection  
//At last set records to the command instance and execute   

Modifying Record with tuple:

For modifying existing records, you need to first fetch old records from table. Then for each record, you can get the tuplevalue instance which can be upadated the same way as we did in create method.Only the command type will change

MultiTupleValue multiTupleValue = (MultiTupleValue) record.getFieldValue(  
//For new records it was like following: MultiTupleValue multiTupleValue = new MultiTupleValue();  
          //Get all tuple values  
        MdmValue[] tuplevals=multiTupleValue.getValues();  
        //Now to update a particular row in a tuple value set, get  its instance from the array   
        TupleValue tupleVal=(TupleValue)tuplevals[ ind]                     
//Rest of the code will be same for setting values to the the tuplevalue  
//if you want to add a new tuple value to the value set create the tuple value instance as below  
     TupleValue tupleVal= MdmValueFactory.createTupleValue();  
//For new row in tuple value set you will have to add the instance to multituplevalue instance.  
//for modifying existing tuple value only you need to update in the tuplevalue instance.  
//At last set records to the command  
                  TableId tableId=reposSchema.getTableId(tablename);  

Deleting Tuple Value:

For deleting tuple values also, you will need to get old record instance.

MultiTupleValue multiTupleValue = (MultiTupleValue)record.getFieldValue(  
//Get old tuple value instances  
TupleValue[] tuplevals=multiTupleValue.getUntouchTupleRecords();  
//Delete old Tuple values  
       int vals_count=tuplevals.length;  
        for(int j=vals_count-1;j>=0;j--)  


Nested Tuple:

Working with nested tuple is similar as above. Only for the child tuple, you need to get the tuple instance from its parent tuple.

MultiTupleValue childTupleValue=((MultiTupleValue)outerTupleVal.

MdmValue[] childTupleVals= childTupleValue.getUntouchTupleRecords();

//Remove tuple value
childTupleValue.removeTupleValue(((TupleValue) childTupleVals[j]).getTupleRecordId());

//Get the Field properties of the child tuple to set field values for the //child tuple
TupleDefinitionId definitionId2 = reposSchema.getTupleDefinition("ChildTupleName").getId();;
TupleDefinitionSchema tupleDefinitionSchema2 = reposSchema.
FieldProperties[] fieldProperties2=tupleDefinitionSchema2.getFields();  

//Add new tuple value
TupleValue  newValue=MdmValueFactory.createTupleValue();
//set field values to the tuple instance

//For modifying existing get the tuple value instance, set the field value
 //by looping on fieldproperties.
To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Sriram Vaithiyanathan

    Good work.  please clarify below mentioned points  1. In Create tuple record line number 21 you have mentioned about object. What is obj talking about? 2. In line number 23, you have mentioned tupleFieldProps. but not initialzed that. what is tupleFieldProps and what are all the parameters need to pass?

    1. Monalisa Biswal Post author

      Thanks Sriram for your response!

      At line 21 I am setting values given by user to the tuple. In my program I have created a custom class to take data from user.obj is the instance of that custom class. It has fields with the same name as the mdm table.I have written a generic methid in the custom class to get field values. o obj.getvalue(tuplefieldname) is giving the user provided value for the passed field.

      You can take data in a two dimensional array as well. so there you can use array[i][j] to access the field value .

      line 23 is using the tuplefieldprops instance declared at line 3. There was a typo error. I changed the name now.It gives the field name, field types and other properties for the tuple fields. so you can write dynamic code for setting values to the tuple fields.

      I can send complete code to your email.

  2. Ozgun Guldas

    Hi Monalisa,

    Thank you for this good work, it’s very helpful. I’m trying to solve a problem and i hope that you can may be help me.

    I have a Tuple in my data model with 5 fields (Types : 3 : Lookup Flat (Mutli Valued), 1 : boolean, 1:  Lookup Main).

    My problem is that i want to set some values into the Lookup Flat fields in this Tuple but i don’t find the solution.

    I can get the values and print them, but i can not set.

    Could you please give me a hand ? I can send you details of my code if you wish.

    Thank in advance.

    Best Regards


Leave a Reply