Skip to content

Commit f1afc65

Browse files
committed
fix firebird support
1 parent b867bd5 commit f1afc65

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@
237237
<version>${hibernate.version}</version>
238238
<scope>provided</scope>
239239
</dependency>
240+
<dependency>
241+
<groupId>org.hibernate.orm</groupId>
242+
<artifactId>hibernate-community-dialects</artifactId>
243+
<version>${hibernate.version}</version>
244+
<scope>provided</scope>
245+
</dependency>
240246

241247
<dependency>
242248
<groupId>org.junit.jupiter</groupId>

src/main/java/com/github/marschall/hibernate/batchsequencegenerator/BatchSequenceGenerator.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,17 @@ private static String buildSelect(String sequenceName, Dialect dialect) {
202202
// https://stackoverflow.com/questions/44472280/cte-based-sequence-generation-with-hsqldb/52329862
203203
return "SELECT " + dialect.getSequenceSupport().getSelectSequenceNextValString(sequenceName) + " FROM UNNEST(SEQUENCE_ARRAY(1, ?, 1))";
204204
}
205-
// if (dialect instanceof org.hibernate.dialect.FirebirdDialect) {
206-
// return "WITH RECURSIVE t(n, level_num) AS ("
207-
// + "SELECT " + dialect.getSequenceSupport().getSelectSequenceNextValString(sequenceName) + " as n, 1 as level_num "
208-
// // difference
209-
// + " FROM rdb$database "
210-
// + "UNION ALL "
211-
// + "SELECT " + dialect.getSequenceSupport().getSelectSequenceNextValString(sequenceName) + " as n, level_num + 1 as level_num "
212-
// + " FROM t "
213-
// + " WHERE level_num < ?) "
214-
// + "SELECT n FROM t";
215-
// }
205+
if (dialect instanceof org.hibernate.community.dialect.FirebirdDialect) {
206+
return "WITH RECURSIVE t(n, level_num) AS ("
207+
+ "SELECT " + dialect.getSequenceSupport().getSelectSequenceNextValString(sequenceName) + " as n, 1 as level_num "
208+
// difference
209+
+ " FROM rdb$database "
210+
+ "UNION ALL "
211+
+ "SELECT " + dialect.getSequenceSupport().getSelectSequenceNextValString(sequenceName) + " as n, level_num + 1 as level_num "
212+
+ " FROM t "
213+
+ " WHERE level_num < ?) "
214+
+ "SELECT n FROM t";
215+
}
216216
return "WITH RECURSIVE t(n, level_num) AS ("
217217
+ "SELECT " + dialect.getSequenceSupport().getSelectSequenceNextValString(sequenceName) + " as n, 1 as level_num "
218218
+ "UNION ALL "

src/test/java/com/github/marschall/hibernate/batchsequencegenerator/BatchSequenceGeneratorIntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.transaction.support.TransactionTemplate;
3232

3333
import com.github.marschall.hibernate.batchsequencegenerator.configurations.Db2Configuration;
34+
import com.github.marschall.hibernate.batchsequencegenerator.configurations.FirebirdConfiguration;
3435
import com.github.marschall.hibernate.batchsequencegenerator.configurations.H2Configuration;
3536
import com.github.marschall.hibernate.batchsequencegenerator.configurations.HibernateConfiguration;
3637
import com.github.marschall.hibernate.batchsequencegenerator.configurations.HsqlConfiguration;
@@ -58,8 +59,8 @@ public static List<Arguments> parameters() {
5859
parameters.add(Arguments.of(Db2Configuration.class, "db2-batched"));
5960
parameters.add(Arguments.of(MariaDbConfiguration.class, "maria-default"));
6061
parameters.add(Arguments.of(MariaDbConfiguration.class, "maria-batched"));
61-
// parameters.add(Arguments.of(FirebirdConfiguration.class, "firebird-default"));
62-
// parameters.add(Arguments.of(FirebirdConfiguration.class, "firebird-batched"));
62+
parameters.add(Arguments.of(FirebirdConfiguration.class, "firebird-default"));
63+
parameters.add(Arguments.of(FirebirdConfiguration.class, "firebird-batched"));
6364
parameters.add(Arguments.of(HsqlConfiguration.class, "hsql-default"));
6465
parameters.add(Arguments.of(HsqlConfiguration.class, "hsql-batched"));
6566
parameters.add(Arguments.of(H2Configuration.class, "h2-default"));

src/test/resources/META-INF/persistence.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
<class>com.github.marschall.hibernate.batchsequencegenerators.entities.ChildEntity</class>
142142

143143
<properties>
144-
<property name="hibernate.dialect" value="org.hibernate.dialect.FirebirdDialect" />
144+
<property name="hibernate.dialect" value="org.hibernate.community.dialect.FirebirdDialect" />
145145
</properties>
146146
</persistence-unit>
147147

@@ -152,7 +152,7 @@
152152
<class>com.github.marschall.hibernate.batchsequencegenerators.entities.ChildEntity</class>
153153

154154
<properties>
155-
<property name="hibernate.dialect" value="org.hibernate.dialect.FirebirdDialect" />
155+
<property name="hibernate.dialect" value="org.hibernate.community.dialect.FirebirdDialect" />
156156
<property name="hibernate.jdbc.batch_size" value="50" />
157157
<property name="hibernate.order_inserts" value="true" />
158158
<property name="hibernate.order_updates" value="true" />

0 commit comments

Comments
 (0)