Rev 114 |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
package br.com.ec.domain.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.ForeignKey;
import br.com.ec.core.generic.identidade.Identidade;
import br.com.ec.core.interfaces.Alterar;
import br.com.ec.core.interfaces.Cadastrar;
@
Entity
@Table
(name=
"sec_orcamento", schema=
"sc_sec")
public class Orcamento
implements Serializable, Identidade,
Cloneable {
private static final long serialVersionUID = 1L
;
private Long sequencial
;
private Categoria categoria
;
private String tipoCategoria
;
private Date dataOrcado
;
private Double valor
;
@
Override
@Transient
public Object getId
() {
return this.
getSequencial();
}
@
Override
public void setId
(Object id
) {
this.
sequencial =
(Long) id
;
}
@Id
@SequenceGenerator
(name =
"sq_orcamento")
@GeneratedValue
(strategy = GenerationType.
IDENTITY)
@Column
(name=
"seq_orcamento", nullable=
false)
public Long getSequencial
() {
return sequencial
;
}
public void setSequencial
(Long sequencial
) {
this.
sequencial = sequencial
;
}
@ManyToOne
@ForeignKey
(name=
"fk_orcamento_categoria")
@JoinColumn
(name=
"seq_categoria")
public Categoria getCategoria
() {
return categoria
;
}
public void setCategoria
(Categoria categoria
) {
this.
categoria = categoria
;
}
@Column
(name=
"tip_categoria", nullable=
false)
@NotNull
(message =
"Parâmetro obrigatório não preenchido: Tipo categoria", groups =
{Cadastrar.
class, Alterar.
class})
public String getTipoCategoria
() {
return tipoCategoria
;
}
public void setTipoCategoria
(String tipoCategoria
) {
this.
tipoCategoria = tipoCategoria
;
}
@Column
(name=
"dat_orcado", nullable=
false)
public Date getDataOrcado
() {
return dataOrcado
;
}
public void setDataOrcado
(Date dataOrcado
) {
this.
dataOrcado = dataOrcado
;
}
@Column
(name=
"val_orcado", nullable=
true)
@NotNull
(message =
"Parâmetro obrigatório não preenchido: Valor orçado", groups =
{Cadastrar.
class, Alterar.
class})
public Double getValor
() {
return valor
;
}
public void setValor
(Double valor
) {
this.
valor = valor
;
}
@
Override
public int hashCode
() {
final int prime =
31;
int result =
1;
result = prime
* result
+
((sequencial ==
null) ? 0 : sequencial.
hashCode());
return result
;
}
@
Override
public boolean equals
(Object obj
) {
if (this == obj
)
return true;
if (obj ==
null)
return false;
if (getClass
() != obj.
getClass())
return false;
Orcamento other =
(Orcamento
) obj
;
if (sequencial ==
null) {
if (other.
sequencial !=
null)
return false;
} else if (!sequencial.
equals(other.
sequencial))
return false;
return true;
}
@
Override
public Orcamento clone
() throws CloneNotSupportedException {
return (Orcamento
) super.
clone();
}
}