Primary key filter for composite key

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Primary key filter for composite key

Suriyanto
Hello,

I am trying to create primary key filter to handle a handful of tables that have composite primary key in my database. My code is similar to below.

public class DBUnitPrimaryKeyFilter implements IColumnFilter {
private Map<String, List<String>> primaryKeys;
public DBUnitPrimaryKeyFilter() {
primaryKeys = new HashMap<>();
primaryKeys.put("table1", Arrays.asList(new String[] {"key1", "key2"}));
}
@Override
public boolean accept(String tableName, Column column) {
if (primaryKeys.containsKey(tableName)) {
return primaryKeys.get(tableName).contains(column.getColumnName());
}
return false;
}
}

But now I have to add every single table and primary key in my database into this hashmap. What is the better way so I don't have to add all tables into the hashmap? Can I fallback to default DBUnit primary key detection for tables that are not in the hashmap?

Thanks,
Suriyanto

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user