Skip to content

Commit

Permalink
XWIKI-22613: Updating the history can take a very long time when ther…
Browse files Browse the repository at this point in the history
…e are a lot of objects (#3788)

XWIKI-22752: Allows indicating in the Hibernate hbm configuration files that an entity should be compressed
XWIKI-22747: Introduce the concept of XWiki Hibernate adapter
  • Loading branch information
tmortagne authored Jan 31, 2025
1 parent 2d9d3c3 commit 173c679
Show file tree
Hide file tree
Showing 33 changed files with 2,033 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String getPreHibernateLiquibaseChangeLog() throws DataMigrationException
PersistentClass persistentClass =
this.hibernateStore.getConfigurationMetadata()
.getEntityBinding(XWikiDocumentIndexingTask.class.getName());
String tableName = this.hibernateStore.getConfiguredTableName(persistentClass);
String tableName = this.hibernateStore.getAdapter().getTableName(persistentClass);
String changeSet = "";
if (exists(databaseMetaData, tableName)) {
saveTasks(session, persistentClass, tableName);
Expand Down Expand Up @@ -138,10 +138,10 @@ protected void hibernateMigrate() throws XWikiException
*/
private boolean exists(DatabaseMetaData databaseMetaData, String tableName) throws SQLException
{
String databaseName = this.hibernateStore.getDatabaseFromWikiName();
String databaseName = this.hibernateStore.getAdapter().getDatabaseFromWikiName();

ResultSet resultSet;
if (this.hibernateStore.isCatalog()) {
if (this.hibernateStore.getAdapter().isCatalog()) {
resultSet = databaseMetaData.getTables(databaseName, null, tableName, null);
} else {
resultSet = databaseMetaData.getTables(null, databaseName, tableName, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.xwiki.context.ExecutionContext;
import org.xwiki.doc.tasks.XWikiDocumentIndexingTask;
import org.xwiki.index.internal.TasksStore;
import org.xwiki.store.hibernate.HibernateAdapter;
import org.xwiki.test.junit5.mockito.ComponentTest;
import org.xwiki.test.junit5.mockito.InjectMockComponents;
import org.xwiki.test.junit5.mockito.MockComponent;
Expand Down Expand Up @@ -102,6 +103,9 @@ class R140300001XWIKI19571DataMigrationTest
@Mock
private Metadata metadata;

@Mock
private HibernateAdapter adapter;

@Mock
private PersistentClass persistentClass;

Expand All @@ -128,8 +132,10 @@ void setUp() throws Exception
when(this.hibernateStore.getConfigurationMetadata()).thenReturn(this.metadata);
when(this.metadata.getEntityBinding(XWikiDocumentIndexingTask.class.getName()))
.thenReturn(this.persistentClass);
when(this.hibernateStore.getConfiguredTableName(this.persistentClass)).thenReturn("XWIKIDOCUMENTINDEXINGQUEUE");
when(this.hibernateStore.getDatabaseFromWikiName()).thenReturn("dbname");
when(this.hibernateStore.getAdapter()).thenReturn(this.adapter);
when(this.adapter.getTableName(this.persistentClass))
.thenReturn("XWIKIDOCUMENTINDEXINGQUEUE");
when(this.adapter.getDatabaseFromWikiName()).thenReturn("dbname");
when(this.connection.getMetaData()).thenReturn(this.databaseMetaData);
when(this.hibernateStore.getConfiguredColumnName(this.persistentClass, "docId")).thenReturn("DOC_ID");
when(this.hibernateStore.getConfiguredColumnName(this.persistentClass, "version")).thenReturn("VERSION");
Expand All @@ -144,7 +150,7 @@ void setUp() throws Exception
@Test
void hibernateMigrateExistsIsCatalog() throws Exception
{
when(this.hibernateStore.isCatalog()).thenReturn(true);
when(this.adapter.isCatalog()).thenReturn(true);
ResultSet resultSet = mock(ResultSet.class);
when(resultSet.next()).thenReturn(true);
when(this.databaseMetaData.getTables("dbname", null, "XWIKIDOCUMENTINDEXINGQUEUE", null)).thenReturn(resultSet);
Expand Down Expand Up @@ -182,7 +188,7 @@ void hibernateMigrateExistsIsCatalog() throws Exception
@Test
void hibernateMigrateExistsIsNotCatalog() throws Exception
{
when(this.hibernateStore.isCatalog()).thenReturn(false);
when(this.adapter.isCatalog()).thenReturn(false);
ResultSet resultSet = mock(ResultSet.class);
when(resultSet.next()).thenReturn(true);
when(this.databaseMetaData.getTables(null, "dbname", "XWIKIDOCUMENTINDEXINGQUEUE", null)).thenReturn(resultSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ protected XWikiRCSNodeContent makePatch(XWikiRCSNodeInfo newnode, XWikiDocument
XWikiRCSNodeInfo latestNode = getLatestNode();
if (latestNode != null) {
int nodesCount = getNodes().size();
int nodesPerFull = context.getWiki() == null ? 5
: Integer.parseInt(context.getWiki().getConfig().getProperty("xwiki.store.rcs.nodesPerFull", "5"));
int nodesPerFull = context.getWiki() == null ? 1
: Integer.parseInt(context.getWiki().getConfig().getProperty("xwiki.store.rcs.nodesPerFull", "1"));
if (nodesPerFull <= 0 || (nodesCount % nodesPerFull) != 0) {
XWikiRCSNodeContent latestContent = latestNode.getContent(context);
latestContent.getPatch().setDiffVersion(latestContent.getPatch().getContent(), doc, context);
Expand Down
Loading

0 comments on commit 173c679

Please sign in to comment.