Domaのバージョンは2.5.0
バッチ更新時、ID以外の列をキーにしてアップデートかけたかったけど、どう書いていいのかドキュメントから見つけられなかったので、メモしておく
@Entity
public Hoge {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer id;
// fugaId, orderNum が複合キー
public Integer fugaId;
public Integer orderNum;
@Dao
public interface HogeDao {
@BatchUpdate(sqlFile=true)
int updateHoges(List<Hoge> hoges);
}
とし、fugaId
とorderNum
で更新をかけにいきたいとする
その場合、更新用SQLは
UPDATE hoge SET /*%population*/ id = id
WHERE fuga_id = /*hoges.fugaId*/1 AND order_num = /*hoges.orderNum*/1
とすればいいっぽい
hoges
はList<Hoge>
ではなくHoge
のインスタンスになる