Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to write logic to insert multiple mappings

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing the problem like I am reading the table relations from xml file for example tale 1 has reference to table2 and table 3 ,table 2 has reference 5and 6 similaru table3 has reference to 7 and 8 here i need to write the logic to insert the following order like first i need to insert table 1 then i need to insert table followed table 5 and 6 next table2 followed by 7 and 8 table here i written the logic like beloe
but it is not working

for (int i = 0; i < (dbprofile.getProfile("export").getTables().getTable()).size(); i++)
flag = false;
Table table = dbprofile.getProfile("export").getTables().getTable().get(i);
for (int cons = 0; cons < table.getConstraints().getConstraint().size(); cons++)
Constraint constraint = table.getConstraints().getConstraint().get(cons);
if (constraint.getReference() == null )
flag = true;
if (cons == table.getConstraints().getConstraint().size() - 1 && flag == true)
{"<<<<<< Table name : >>>>>>>>"+table.getName());
if (tableIds == null)
tableIds = new StringBuilder();
} else
tableIds.append("," + table.getId().toString());
}// for cons
}// for i

canyone sujjest me
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags and punctuation. If I understand you correctly then you want to write the values from a xml-file to a database. Can't you just insert all the tables first and then add the relations? If not and the constraints are not ordered then you'll need to build a data-structure that houses the constraints and let's you extract the proper order of inserting them.
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic