Search in sources :

Example 21 with RelationalPersistentProperty

use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.

the class BasicJdbcPersistentPropertyUnitTests method detectsReverseColumnNameFromColumnAnnotation.

// DATAJDBC-331
@Test
public void detectsReverseColumnNameFromColumnAnnotation() {
    String propertyName = "someList";
    RelationalPersistentProperty listProperty = // 
    context.getRequiredPersistentEntity(// 
    WithCollections.class).getRequiredPersistentProperty(propertyName);
    PersistentPropertyPathExtension path = getPersistentPropertyPath(DummyEntity.class, propertyName);
    assertThat(listProperty.getKeyColumn()).isEqualTo(quoted("WITH_COLLECTIONS_KEY"));
    assertThat(listProperty.getReverseColumnName(path)).isEqualTo(quoted("some_value"));
}
Also used : PersistentPropertyPathExtension(org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension) BasicRelationalPersistentProperty(org.springframework.data.relational.core.mapping.BasicRelationalPersistentProperty) RelationalPersistentProperty(org.springframework.data.relational.core.mapping.RelationalPersistentProperty) Test(org.junit.jupiter.api.Test)

Example 22 with RelationalPersistentProperty

use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.

the class BasicRelationalConverterUnitTests method shouldUseConvertingPropertyAccessor.

// DATAJDBC-235
@Test
@SuppressWarnings("unchecked")
void shouldUseConvertingPropertyAccessor() {
    RelationalPersistentEntity<MyEntity> entity = (RelationalPersistentEntity) context.getRequiredPersistentEntity(MyEntity.class);
    MyEntity instance = new MyEntity();
    PersistentPropertyAccessor<MyEntity> accessor = converter.getPropertyAccessor(entity, instance);
    RelationalPersistentProperty property = entity.getRequiredPersistentProperty("flag");
    accessor.setProperty(property, "1");
    assertThat(instance.isFlag()).isTrue();
}
Also used : RelationalPersistentEntity(org.springframework.data.relational.core.mapping.RelationalPersistentEntity) RelationalPersistentProperty(org.springframework.data.relational.core.mapping.RelationalPersistentProperty) Test(org.junit.jupiter.api.Test)

Aggregations

RelationalPersistentProperty (org.springframework.data.relational.core.mapping.RelationalPersistentProperty)22 Test (org.junit.jupiter.api.Test)9 PersistentPropertyPathExtension (org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension)5 BasicRelationalPersistentProperty (org.springframework.data.relational.core.mapping.BasicRelationalPersistentProperty)3 SQLType (java.sql.SQLType)2 ArrayList (java.util.ArrayList)2 SoftAssertions (org.assertj.core.api.SoftAssertions)2 RelationalPersistentEntity (org.springframework.data.relational.core.mapping.RelationalPersistentEntity)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 SqlSession (org.apache.ibatis.session.SqlSession)1 Assertions (org.assertj.core.api.Assertions)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 ArgumentMatchers (org.mockito.ArgumentMatchers)1 Mockito (org.mockito.Mockito)1 Example (org.springframework.data.domain.Example)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1