spring-data-dynamodb icon indicating copy to clipboard operation
spring-data-dynamodb copied to clipboard

@DynamoDBAttribute variable is null (or default value) in paging sort

Open webgori opened this issue 7 years ago • 0 comments

first, sorry for bad english

Expected Behavior

userIdx, paymentType variable value is 1

image

Actual Behavior

userIdx, paymentType variable value is default value (0)

image

Steps to Reproduce the Problem

  1. connect local dynamodb
  2. create table
  3. save data
  4. paging and sort like findAllByMessageOrderByRegDateDesc

Specifications

  • Spring Data DynamoDB Version: 4.5.7
  • Spring Data Version: 1.5.15.RELEASE
  • AWS SDK Version: 1.11.388
  • Java Version: 8
  • Platform Details: windows 10
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIndexHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIndexRangeKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverted;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter;
import java.time.LocalDateTime;

@DynamoDBTable(tableName = "gz_feed")
public class Feed {
  private String idx;
  private int userIdx;
  private String message;
  private int paymentType;
  private LocalDateTime regDate;

  @DynamoDBHashKey
  @DynamoDBAutoGeneratedKey
  public String getIdx() {
    return idx;
  }

  @DynamoDBAttribute
  public int getUserIdx() {
    return userIdx;
  }

  @DynamoDBAttribute
  @DynamoDBIndexHashKey(globalSecondaryIndexName = "aaa")
  public String getMessage() {
    return message;
  }

  //@DynamoDBIndexRangeKey(attributeName = "PaymentType", globalSecondaryIndexName = "aaa")
  @DynamoDBAttribute
  public int getPaymentType() {
    return paymentType;
  }

  @DynamoDBTypeConverted(converter = LocalDateTimeConverter.class)
  @DynamoDBAttribute
  @DynamoDBIndexRangeKey(globalSecondaryIndexName = "aaa")
  public LocalDateTime getRegDate() {
    return regDate;
  }

  public void setIdx(String idx) {
    this.idx = idx;
  }

  public void setUserIdx(int userIdx) {
    this.userIdx = userIdx;
  }

  public void setMessage(String message) {
    this.message = message;
  }

  public void setPaymentType(int paymentType) {
    this.paymentType = paymentType;
  }

  public void setRegDate(LocalDateTime regDate) {
    this.regDate = regDate;
  }

  static public class LocalDateTimeConverter implements
      DynamoDBTypeConverter<String, LocalDateTime> {

    @Override
    public String convert( final LocalDateTime time ) {

      return time.toString();
    }

    @Override
    public LocalDateTime unconvert( final String stringValue ) {

      return LocalDateTime.parse(stringValue);
    }
  }
}
import org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository;
import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.socialsignin.spring.data.dynamodb.repository.EnableScanCount;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

@EnableScan
@EnableScanCount
public interface FeedPagingRepository extends DynamoDBPagingAndSortingRepository<Feed, String> {
  Page<Feed> findAllByMessageOrderByRegDateDesc(String message, Pageable pageable);
}

webgori avatar Aug 21 '18 01:08 webgori