com.invms.x.entities.basis.PowerEntity Maven / Gradle / Ivy
The newest version!
package com.invms.x.entities.basis;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
@Table(name = "t_basis_power", indexes = { @Index(name = "i_power_category", columnList = "c_category"), @Index(name = "i_power_source_id", columnList = "f_source_id"), @Index(name = "i_power_target_id", columnList = "f_target_id") })
@Entity
public class PowerEntity extends BaseIdedEntity implements Serializable {
private static final long serialVersionUID = -6903443741026613345L;
@Embeddable
public static class Id implements Serializable {
private static final long serialVersionUID = 7792093260763046995L;
@Column(name = "c_category", length = 32, nullable = false)
protected String category;
@Column(name = "f_source_id", length = 32, nullable = false)
protected String sourceId;
@Column(name = "f_target_id", length = 32, nullable = false)
protected String targetId;
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getSourceId() {
return sourceId;
}
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}
public String getTargetId() {
return targetId;
}
public void setTargetId(String targetId) {
this.targetId = targetId;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Id) {
Id id = (Id) obj;
return toString().equals(id.toString());
}
return false;
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public String toString() {
return String.format("{\"category\":\"%s\",\"sourceId\":\"%s\",\"targetId\":\"%s\"}", category, sourceId, targetId);
}
}
@EmbeddedId
@Column(nullable = false)
protected Id id;
@Override
public Id getId() {
return id;
}
@Override
public void setId(Id id) {
this.id = id;
}
public PowerEntity() {
id = new Id();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy