-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose property
quarkus.hibernate-orm.flush.mode
- Loading branch information
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...oyment/src/test/java/io/quarkus/hibernate/orm/config/properties/ConfigPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.quarkus.hibernate.orm.config.properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.transaction.Transactional; | ||
|
||
import org.hibernate.FlushMode; | ||
import org.hibernate.Session; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.orm.PersistenceUnit; | ||
import io.quarkus.hibernate.orm.config.properties.defaultpu.MyEntityForDefaultPU; | ||
import io.quarkus.hibernate.orm.config.properties.overridespu.MyEntityForOverridesPU; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
/** | ||
* Tests that configuration properties set in Quarkus are translated to the right key and value in Hibernate ORM. | ||
*/ | ||
public class ConfigPropertiesTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer( | ||
() -> ShrinkWrap.create(JavaArchive.class) | ||
.addPackage(MyEntityForDefaultPU.class.getPackage()) | ||
.addPackage(MyEntityForOverridesPU.class.getPackage())) | ||
.withConfigurationResource("application.properties") | ||
.overrideConfigKey("quarkus.hibernate-orm.packages", MyEntityForDefaultPU.class.getPackageName()) | ||
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".packages", MyEntityForOverridesPU.class.getPackageName()) | ||
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".datasource", "<default>") | ||
// Overrides to test that Quarkus configuration properties are taken into account | ||
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".flush.mode", "always"); | ||
|
||
@Inject | ||
Session sessionForDefaultPU; | ||
|
||
@Inject | ||
@PersistenceUnit("overrides") | ||
Session sessionForOverridesPU; | ||
|
||
@Test | ||
@Transactional | ||
public void propertiesAffectingSession() { | ||
assertThat(sessionForDefaultPU.getHibernateFlushMode()).isEqualTo(FlushMode.AUTO); | ||
assertThat(sessionForOverridesPU.getHibernateFlushMode()).isEqualTo(FlushMode.ALWAYS); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
.../test/java/io/quarkus/hibernate/orm/config/properties/defaultpu/MyEntityForDefaultPU.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.hibernate.orm.config.properties.defaultpu; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
|
||
@Entity | ||
public class MyEntityForDefaultPU { | ||
@Id | ||
private long id; | ||
|
||
private String name; | ||
|
||
public MyEntityForDefaultPU() { | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...t/java/io/quarkus/hibernate/orm/config/properties/overridespu/MyEntityForOverridesPU.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.hibernate.orm.config.properties.overridespu; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
|
||
@Entity | ||
public class MyEntityForOverridesPU { | ||
@Id | ||
private long id; | ||
|
||
private String name; | ||
|
||
public MyEntityForOverridesPU() { | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters