Search in sources :

Example 11 with PersistentPropertyPathExtension

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

the class PersistentPropertyPathExtensionUnitTests method equalsWorks.

// GH--1164
@Test
void equalsWorks() {
    PersistentPropertyPathExtension root1 = extPath(entity);
    PersistentPropertyPathExtension root2 = extPath(entity);
    PersistentPropertyPathExtension path1 = extPath("withId");
    PersistentPropertyPathExtension path2 = extPath("withId");
    assertSoftly(softly -> {
        softly.assertThat(root1).describedAs("root is equal to self").isEqualTo(root1);
        softly.assertThat(root2).describedAs("root is equal to identical root").isEqualTo(root1);
        softly.assertThat(path1).describedAs("path is equal to self").isEqualTo(path1);
        softly.assertThat(path2).describedAs("path is equal to identical path").isEqualTo(path1);
        softly.assertThat(path1).describedAs("path is not equal to other path").isNotEqualTo(extPath("entityId"));
        softly.assertThat(root1).describedAs("root is not equal to path").isNotEqualTo(path1);
        softly.assertThat(path1).describedAs("path is not equal to root").isNotEqualTo(root1);
    });
}
Also used : PersistentPropertyPathExtension(org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension) Test(org.junit.jupiter.api.Test)

Example 12 with PersistentPropertyPathExtension

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

the class BasicJdbcPersistentPropertyUnitTests method detectsKeyColumnOverrideNameFromMappedCollectionAnnotation.

// DATAJDBC-331
@Test
public void detectsKeyColumnOverrideNameFromMappedCollectionAnnotation() {
    RelationalPersistentProperty listProperty = // 
    context.getRequiredPersistentEntity(// 
    WithCollections.class).getRequiredPersistentProperty("overrideList");
    PersistentPropertyPathExtension path = getPersistentPropertyPath(WithCollections.class, "overrideList");
    assertThat(listProperty.getKeyColumn()).isEqualTo(quoted("override_key"));
    assertThat(listProperty.getReverseColumnName(path)).isEqualTo(quoted("override_id"));
}
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 13 with PersistentPropertyPathExtension

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

the class BasicJdbcPersistentPropertyUnitTests method detectsAnnotatedColumnAndKeyName.

// DATAJDBC-218
@Test
public void detectsAnnotatedColumnAndKeyName() {
    String propertyName = "someList";
    RelationalPersistentProperty listProperty = entity.getRequiredPersistentProperty(propertyName);
    PersistentPropertyPathExtension path = getPersistentPropertyPath(DummyEntity.class, propertyName);
    assertThat(listProperty.getReverseColumnName(path)).isEqualTo(quoted("dummy_column_name"));
    assertThat(listProperty.getKeyColumn()).isEqualTo(quoted("dummy_key_column_name"));
}
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 14 with PersistentPropertyPathExtension

use of org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension 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 15 with PersistentPropertyPathExtension

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

the class JdbcIdentifierBuilderUnitTests method qualifiersForMaps.

// DATAJDBC-326
@Test
public void qualifiersForMaps() {
    PersistentPropertyPathExtension path = getPath("children");
    Identifier identifier = // 
    JdbcIdentifierBuilder.forBackReferences(converter, path, // 
    "parent-eins").withQualifier(path, // 
    "map-key-eins").build();
    // 
    assertThat(identifier.getParts()).extracting("name", "value", // 
    "targetType").containsExactlyInAnyOrder(// 
    tuple(quoted("DUMMY_ENTITY"), "parent-eins", UUID.class), // 
    tuple(quoted("DUMMY_ENTITY_KEY"), "map-key-eins", String.class));
}
Also used : SqlIdentifier(org.springframework.data.relational.core.sql.SqlIdentifier) PersistentPropertyPathExtension(org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

PersistentPropertyPathExtension (org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension)16 Test (org.junit.jupiter.api.Test)6 RelationalPersistentProperty (org.springframework.data.relational.core.mapping.RelationalPersistentProperty)5 BasicRelationalPersistentProperty (org.springframework.data.relational.core.mapping.BasicRelationalPersistentProperty)3 UUID (java.util.UUID)2 SqlIdentifier (org.springframework.data.relational.core.sql.SqlIdentifier)2 Nullable (org.springframework.lang.Nullable)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 JdbcIdentifierBuilder (org.springframework.data.jdbc.core.convert.JdbcIdentifierBuilder)1 PersistentPropertyPath (org.springframework.data.mapping.PersistentPropertyPath)1 DbAction (org.springframework.data.relational.core.conversion.DbAction)1 Column (org.springframework.data.relational.core.sql.Column)1 Expression (org.springframework.data.relational.core.sql.Expression)1 SelectBuilder (org.springframework.data.relational.core.sql.SelectBuilder)1 Table (org.springframework.data.relational.core.sql.Table)1 Part (org.springframework.data.repository.query.parser.Part)1 PartTree (org.springframework.data.repository.query.parser.PartTree)1