aspose file tools*
The moose likes Java in General and the fly likes How to write logic to insert multiple mappings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to write logic to insert multiple mappings" Watch "How to write logic to insert multiple mappings" New topic
Author

How to write logic to insert multiple mappings

nalamati satyanarayana
Ranch Hand

Joined: Dec 16, 2005
Posts: 36
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)
{
log.info("<<<<<< Table name : >>>>>>>>"+table.getName());
SQLOperations.dbimport(table);
if (tableIds == null)
{
tableIds = new StringBuilder();
tableIds.append(table.getId().toString());
} else
{
tableIds.append("," + table.getId().toString());
}
}
}// for cons
}// for i


canyone sujjest me
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write logic to insert multiple mappings