Skip to content

Commit

Permalink
chore: update AggregateAddressTxBalance Id
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-DucPhung committed May 7, 2024
1 parent 48d3d37 commit 15fafba
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.cardanofoundation.explorer.common.entity.compositeKey;

import java.time.LocalDate;

import jakarta.persistence.Column;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Builder
public class AggAddressTxBalanceId {
@Column(name = "address_id", insertable = false, updatable = false)
protected Long addressId;

@Column(name = "day", insertable = false, updatable = false)
private LocalDate day;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
import java.math.BigInteger;
import java.time.LocalDate;

import jakarta.persistence.AttributeOverride;
import jakarta.persistence.AttributeOverrides;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Digits;

Expand All @@ -13,7 +18,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;

import org.cardanofoundation.explorer.common.entity.ledgersync.BaseEntity;
import org.cardanofoundation.explorer.common.entity.compositeKey.AggAddressTxBalanceId;
import org.cardanofoundation.explorer.common.entity.validation.Word128Type;

@Entity
Expand All @@ -22,18 +27,32 @@
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class AggregateAddressTxBalance extends BaseEntity {
@IdClass(AggAddressTxBalanceId.class)
public class AggregateAddressTxBalance {

@Column(name = "stake_address_id")
protected Long stakeAddressId;

@Id
@Column(name = "address_id")
protected Long addressId;

@Id
@Column(name = "day")
private LocalDate day;

@Column(name = "balance", nullable = false, precision = 39)
@Word128Type
private @Digits(integer = 39, fraction = 0) BigInteger balance;

@Column(name = "day")
private LocalDate day;
@Embedded
@AttributeOverrides({
@AttributeOverride(
name = "address_id",
column = @Column(name = "address_id", insertable = false, updatable = false)),
@AttributeOverride(
name = "day",
column = @Column(name = "day", insertable = false, updatable = false)),
})
private AggAddressTxBalanceId id;
}

0 comments on commit 15fafba

Please sign in to comment.