mercredi 24 juin 2015

What exactly represent this "Hibernate" class mapping?

I am working on a Java web application that I think use Hibernate and I am not so into Hibernate so I have the following doubt:

I have a model class named ReaDichiarazioneIntento that map a database table named REA_DICHIARAZIONE_INTENTO, something like this:

@javax.persistence.IdClass(it.enel.wearea.entity.ReaDichiarazioneIntentoPK.class)
@javax.persistence.Table(name = "REA_DICHIARAZIONE_INTENTO", schema = "EDIWEA")
@Entity
public class ReaDichiarazioneIntento implements Cloneable {

    private Integer idDichiarazione;

    @javax.persistence.Column(name = "ID_DICHIARAZIONE")
    @Id
    public Integer getIdDichiarazione() {
        return idDichiarazione;
    }

    public void setIdDichiarazione(Integer idDichiarazione) {
        this.idDichiarazione = idDichiarazione;
    }

    private Integer idCliente;

    @javax.persistence.Column(name = "ID_CLIENTE")
    @Basic
    public Integer getIdCliente() {
        return idCliente;
    }

    public void setIdCliente(Integer idCliente) {
        this.idCliente = idCliente;
    }

    ...................................................................
    ...................................................................
    ...................................................................
    SOME OTHER FIELDS AND RELATED GETTER AND SETTER METHODS
    ...................................................................
    ...................................................................
    ...................................................................

}

Ok I have some doubts about this class. My doubt are:

1) Is it using Hibernate for mapping the class to the database table? Or what? I know that to map a database table to a class I have to do something like:

@Entity
@Table(name = "REA_DICHIARAZIONE_INTENTO")

Why in this project do:

@javax.persistence.IdClass(it.enel.wearea.entity.ReaDichiarazioneIntentoPK.class)
@javax.persistence.Table(name = "REA_DICHIARAZIONE_INTENTO", schema = "EDIWEA")
@Entity

What is the difference between the @Table(name = "REA_DICHIARAZIONE_INTENTO") annotation and the @javax.persistence.Table(name = "REA_DICHIARAZIONE_INTENTO", schema = "EDIWEA") annotation (used in my project)?

2) The second doubt is related to this annotation:

@javax.persistence.IdClass(it.enel.wearea.entity.ReaDichiarazioneIntentoPK.class)

What exactly means?

Tnx

Aucun commentaire:

Enregistrer un commentaire