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

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 committed Jan 10, 2025
1 parent 42d499b commit 4e62720
Show file tree
Hide file tree
Showing 28 changed files with 1,610 additions and 314 deletions.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,17 @@

<!-- Database connectors -->
<!-- Exclude optional dependencies -->
<dependency>
<groupId>${hsqldb.groupId}</groupId>
<artifactId>${hsqldb.artifactId}</artifactId>
<version>${hsqldb.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${mysql.groupId}</groupId>
<artifactId>${mysql.artifactId}</artifactId>
Expand Down Expand Up @@ -1177,6 +1188,7 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>vue</artifactId>
Expand Down
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,7 +138,7 @@ 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()) {
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 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 4e62720

Please sign in to comment.