Revision 3152
Added by Matt Jones almost 18 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
1548 | 1548 |
} |
1549 | 1549 |
|
1550 | 1550 |
/** |
1551 |
* Insert the paths from the pathList into the xml_path_index table on the
|
|
1551 |
* Insert the paths from the pathList into the xml_path_index table on the
|
|
1552 | 1552 |
* database. |
1553 | 1553 |
* |
1554 | 1554 |
* @param conn the database connection to use, keeping a single transaction |
... | ... | |
1556 | 1556 |
* @throws SQLException if there is an error inserting into the db |
1557 | 1557 |
*/ |
1558 | 1558 |
private void updatePathIndex(DBConnection conn, HashMap pathsFound) |
1559 |
throws SQLException {
|
|
1560 |
// Increase usage count for the connection
|
|
1559 |
throws SQLException {
|
|
1560 |
// Increase usage count for the connection
|
|
1561 | 1561 |
conn.increaseUsageCount(1); |
1562 | 1562 |
|
1563 | 1563 |
// Create an insert statement to reuse for all of the path |
1564 | 1564 |
// insertions |
1565 | 1565 |
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO " |
1566 |
+ "xml_path_index (nodeid, docid, path, nodedata, "
|
|
1566 |
+ "xml_path_index (docid, path, nodedata, " |
|
1567 | 1567 |
+ "nodedatanumerical, parentnodeid)" |
1568 |
+ " VALUES (?, ?, ?, ?, ?, ?)");
|
|
1568 |
+ " VALUES (?, ?, ?, ?, ?)"); |
|
1569 | 1569 |
|
1570 | 1570 |
// Step through the hashtable and insert each of the path values |
1571 | 1571 |
Iterator it = pathsFound.values().iterator(); |
1572 | 1572 |
while (it.hasNext()) { |
1573 |
PathIndexEntry entry = (PathIndexEntry)it.next();
|
|
1573 |
PathIndexEntry entry = (PathIndexEntry)it.next();
|
|
1574 | 1574 |
|
1575 |
pstmt.setLong(1, entry.nodeId); |
|
1576 |
pstmt.setString(2,entry.docid); |
|
1577 |
pstmt.setString(3, entry.path); |
|
1578 |
pstmt.setString(4, entry.nodeData); |
|
1579 |
pstmt.setFloat(5, entry.nodeDataNumerical); |
|
1580 |
pstmt.setLong(6, entry.parentId); |
|
1581 |
pstmt.execute(); |
|
1575 |
pstmt.setString(1,entry.docid); |
|
1576 |
pstmt.setString(2, entry.path); |
|
1577 |
pstmt.setString(3, entry.nodeData); |
|
1578 |
pstmt.setFloat(4, entry.nodeDataNumerical); |
|
1579 |
pstmt.setLong(5, entry.parentId); |
|
1580 |
pstmt.execute(); |
|
1582 | 1581 |
} |
1583 | 1582 |
// Close the database statement |
1584 | 1583 |
pstmt.close(); |
Also available in: Unified diff
Fixed the implementation of the buildIndex function which was not
working for new document insertions. A previous fix in updatePathIndex
for ATTRIBUTE data inadvertantly caused a foreign key duplication
exception for insertions of ELEMENT nodes when multiple relative paths
exist. This fix simply reverts to the old behaviour of allowing the
primary key of xml_path_index to be set using its sequence instead of
manually matching it to the xml_nodes.nodeid (which the current code
did and which caused the duplicate key problem). See bug 2469 for
related details regaring the indexing changes.