我正在研究一个我认为使用Hibernate的Java Web应用程序,而我对Hibernate并不是这样,所以我有以下疑问:
我有一个名为 ReaDichiarazioneIntento 的模型类,它映射名为 REA_DICHIARAZIONE_INTENTO 的数据库表,如下所示:
@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
...................................................................
...................................................................
...................................................................
}
好的,我对这门课有些怀疑。我怀疑是:
1)是否使用 Hibernate 将类映射到数据库表?或者是什么?我知道要将数据库表映射到类,我必须执行以下操作:
@Entity
@Table(name = "REA_DICHIARAZIONE_INTENTO")
为什么在这个项目中做:
@javax.persistence.IdClass(it.enel.wearea.entity.ReaDichiarazioneIntentoPK.class)
@javax.persistence.Table(name = "REA_DICHIARAZIONE_INTENTO", schema = "EDIWEA")
@Entity
@Table(name =“REA_DICHIARAZIONE_INTENTO”)注释与 @ javax.persistence.Table(name =“REA_DICHIARAZIONE_INTENTO”,schema =“EDIWEA”)之间有什么区别? 注释(在我的项目中使用)?
2)第二个疑问与这个注释有关:
@javax.persistence.IdClass(it.enel.wearea.entity.ReaDichiarazioneIntentoPK.class)
究竟意味着什么?
3)最后的疑问与数据库中类字段与表列之间的映射有关。为什么只在getter方法上完成,而不是直接在字段名称上完成?
TNX