

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 適用於 Java 的 SDK 第 1 版和第 2 版之間的流暢設定器差異
<a name="dynamodb-migrate-fluent-setters"></a>

您可以在適用於 V1 POJOs 搭配流暢的設定器，以及搭配自 2.30.29 版以來的 V2。 DynamoDB 

例如，下列 POJO 會從 `setName`方法傳回`Customer`執行個體：

```
// V1

@DynamoDBTable(tableName ="Customer")
public class Customer{
  private String name;
  // Other attributes and methods not shown.
  public Customer setName(String name){
     this.name = name;
     return this;
  }
}
```

不過，如果您使用 2.30.29 之前的 V2 版本， 會`setName`傳回`name`值為 的`Customer`執行個體`null`。

```
// V2 prior to version 2.30.29.

@DynamoDbBean
public class Customer{
  private String name;
  // Other attributes and methods not shown.
  public Customer setName(String name){ 
     this.name = name;
     return this;  // Bug: returns this instance with a `name` value of `null`.
  }
}
```

```
// Available in V2 since version 2.30.29.

@DynamoDbBean
public class Customer{
  private String name;
  // Other attributes and methods not shown.
  public Customer setName(String name){ 
     this.name = name;
     return this;  // Returns this instance for method chaining with the `name` value set.
  }
}
```