-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.com
Description
It's possible to overrides Entity column options ?
I have two classes:
@Setter
@Getter
@Entity(name="post_post")
public class PostEntity {
// ...
@CreatedBy
@Column(name = "created_by", nullable = false, insertable = false, updatable = false)
UUID createdBy;
@LastModifiedBy
@Column(name = "updated_by", nullable = false, insertable = false, updatable = false)
UUID updatedBy;
}
@DataJpaTest
@ActiveProfiles("qa")
class PersistPostIT {
@Test
@Disable // You have to remove these lines in PostEntity before ", nullable = false, insertable = false, updatable = false"
void shouldSuccesssfullyPersist(){}
}In META-INF/orm-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings
xmlns="https://jakarta.ee/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence/orm
https://jakarta.ee/xml/ns/persistence/orm_3_0.xsd"
version="3.0">
<entity class="com.example.PostEntity" access="FIELD">
<table name="PostEntity" schema="public"/>
<attributes>
<basic name="createdBy">
<column name="created_by" insertable="true" updatable="true" nullable="false"/>
</basic>
<basic name="updatedBy">
<column name="updated_by" insertable="true" updatable="true" nullable="true"/>
</basic>
</attributes>
</entity>
</entity-mappings>The options in application-qa.yaml to call orm-test.xml or more ? I have no idea.
Stackoverflow origin question: https://stackoverflow.com/questions/79840437/how-to-overrides-entity-field-in-tests-with-spring-boot-v4-hibernate
Thanks
Metadata
Metadata
Assignees
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.com