Hi,
i've a class mapped with an EmbeddedId. My problem is when i do a simply hql select, it returns me a List with correct number of elements (size correct), bu all this object are "null". If i execute the sql (sql shown in the log), it works correctly.
Is moore clearly with code:
My mapped class
Code:
package edu.upc.domain.actual;
// default package
// Generated 29-jun-2009 12:26:40 by Hibernate Tools 3.2.4.GA
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import sun.security.util.BigInt;
/**
* Zyco generated by hbm2java
*/
@Entity
@Table(name = "ZYCO", schema = "CS", uniqueConstraints = @UniqueConstraint(columnNames = {
"NUDOSS", "DATCON" }))
public class Zyco implements java.io.Serializable {
private ZycoId id;
private Zy00 zy00;
private String ie="ieieie";
public Zyco() {
}
public Zyco(ZycoId id, Zy00 zy00) {
this.id = id;
this.zy00 = zy00;
}
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "nudoss", column = @Column(name = "NUDOSS", nullable = false, precision = 38, scale = 0)),
@AttributeOverride(name = "datcon", column = @Column(name = "DATCON", nullable = false, length = 7)),
@AttributeOverride(name = "datfin", column = @Column(name = "DATFIN", length = 7)),
@AttributeOverride(name = "typcon", column = @Column(name = "TYPCON", nullable = false, length = 3)),
@AttributeOverride(name = "natcon", column = @Column(name = "NATCON", length = 2)),
@AttributeOverride(name = "datpre", column = @Column(name = "DATPRE", length = 7)),
@AttributeOverride(name = "horheb", column = @Column(name = "HORHEB", precision = 4)),
@AttributeOverride(name = "nbheuc", column = @Column(name = "NBHEUC", precision = 4)),
@AttributeOverride(name = "orgint", column = @Column(name = "ORGINT", length = 6)),
@AttributeOverride(name = "durann", column = @Column(name = "DURANN", precision = 2, scale = 0)),
@AttributeOverride(name = "durmoi", column = @Column(name = "DURMOI", precision = 2, scale = 0)),
@AttributeOverride(name = "durjou", column = @Column(name = "DURJOU", precision = 2, scale = 0)),
@AttributeOverride(name = "nbqday", column = @Column(name = "NBQDAY", precision = 1, scale = 0)),
@AttributeOverride(name = "natcom", column = @Column(name = "NATCOM", length = 8)),
@AttributeOverride(name = "debess", column = @Column(name = "DEBESS", length = 7)),
@AttributeOverride(name = "finess", column = @Column(name = "FINESS", length = 7)),
@AttributeOverride(name = "nbrpro", column = @Column(name = "NBRPRO", precision = 2, scale = 0)),
@AttributeOverride(name = "typbon", column = @Column(name = "TYPBON", length = 2)),
@AttributeOverride(name = "debbon", column = @Column(name = "DEBBON", length = 7)),
@AttributeOverride(name = "finbon", column = @Column(name = "FINBON", length = 7)),
@AttributeOverride(name = "nuinem", column = @Column(name = "NUINEM", length = 7)),
@AttributeOverride(name = "motini", column = @Column(name = "MOTINI", length = 2)),
@AttributeOverride(name = "motfin", column = @Column(name = "MOTFIN", length = 2)),
@AttributeOverride(name = "tipoco", column = @Column(name = "TIPOCO", length = 1)),
@AttributeOverride(name = "observ", column = @Column(name = "OBSERV", length = 50)),
@AttributeOverride(name = "perpru", column = @Column(name = "PERPRU", precision = 2, scale = 0)),
@AttributeOverride(name = "obser2", column = @Column(name = "OBSER2", length = 250)) })
public ZycoId getId() {
return this.id;
}
public void setId(ZycoId id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "NUDOSS", nullable = false, insertable = false, updatable = false)
public Zy00 getZy00() {
return this.zy00;
}
public void setZy00(Zy00 zy00) {
this.zy00 = zy00;
}
}
My Embeddable class used in class before:
Code:
package edu.upc.domain.actual;
// default package
// Generated 29-jun-2009 12:26:40 by Hibernate Tools 3.2.4.GA
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
/**
* ZycoId generated by hbm2java
*/
@Embeddable
public class ZycoId implements java.io.Serializable {
private BigDecimal nudoss;
private Date datcon;
private Date datfin;
private String typcon;
private String natcon;
private Date datpre;
private BigDecimal horheb;
private BigDecimal nbheuc;
private String orgint;
private Byte durann;
private Byte durmoi;
private Byte durjou;
private Boolean nbqday;
private String natcom;
private Date debess;
private Date finess;
private Byte nbrpro;
private String typbon;
private Date debbon;
private Date finbon;
private String nuinem;
private String motini;
private String motfin;
private Character tipoco;
private String observ;
private Byte perpru;
private String obser2;
public ZycoId() {
}
public ZycoId(BigDecimal nudoss, Date datcon, String typcon) {
this.nudoss = nudoss;
this.datcon = datcon;
this.typcon = typcon;
}
@Column(name = "NUDOSS", nullable = false, precision = 38, scale = 0)
public BigDecimal getNudoss() {
return this.nudoss;
}
public void setNudoss(BigDecimal nudoss) {
this.nudoss = nudoss;
}
@Column(name = "DATCON", nullable = false, length = 7)
public Date getDatcon() {
return this.datcon;
}
public void setDatcon(Date datcon) {
this.datcon = datcon;
}
@Column(name = "DATFIN", length = 7)
public Date getDatfin() {
return this.datfin;
}
public void setDatfin(Date datfin) {
this.datfin = datfin;
}
@Column(name = "TYPCON", nullable = false, length = 3)
public String getTypcon() {
return this.typcon;
}
public void setTypcon(String typcon) {
this.typcon = typcon;
}
@Column(name = "NATCON", length = 2)
public String getNatcon() {
return this.natcon;
}
public void setNatcon(String natcon) {
this.natcon = natcon;
}
@Column(name = "DATPRE", length = 7)
public Date getDatpre() {
return this.datpre;
}
public void setDatpre(Date datpre) {
this.datpre = datpre;
}
@Column(name = "HORHEB", precision = 4)
public BigDecimal getHorheb() {
return this.horheb;
}
public void setHorheb(BigDecimal horheb) {
this.horheb = horheb;
}
@Column(name = "NBHEUC", precision = 4)
public BigDecimal getNbheuc() {
return this.nbheuc;
}
public void setNbheuc(BigDecimal nbheuc) {
this.nbheuc = nbheuc;
}
@Column(name = "ORGINT", length = 6)
public String getOrgint() {
return this.orgint;
}
public void setOrgint(String orgint) {
this.orgint = orgint;
}
@Column(name = "DURANN", precision = 2, scale = 0)
public Byte getDurann() {
return this.durann;
}
public void setDurann(Byte durann) {
this.durann = durann;
}
@Column(name = "DURMOI", precision = 2, scale = 0)
public Byte getDurmoi() {
return this.durmoi;
}
public void setDurmoi(Byte durmoi) {
this.durmoi = durmoi;
}
@Column(name = "DURJOU", precision = 2, scale = 0)
public Byte getDurjou() {
return this.durjou;
}
public void setDurjou(Byte durjou) {
this.durjou = durjou;
}
@Column(name = "NBQDAY", precision = 1, scale = 0)
public Boolean getNbqday() {
return this.nbqday;
}
public void setNbqday(Boolean nbqday) {
this.nbqday = nbqday;
}
@Column(name = "NATCOM", length = 8)
public String getNatcom() {
return this.natcom;
}
public void setNatcom(String natcom) {
this.natcom = natcom;
}
@Column(name = "DEBESS", length = 7)
public Date getDebess() {
return this.debess;
}
public void setDebess(Date debess) {
this.debess = debess;
}
@Column(name = "FINESS", length = 7)
public Date getFiness() {
return this.finess;
}
public void setFiness(Date finess) {
this.finess = finess;
}
@Column(name = "NBRPRO", precision = 2, scale = 0)
public Byte getNbrpro() {
return this.nbrpro;
}
public void setNbrpro(Byte nbrpro) {
this.nbrpro = nbrpro;
}
@Column(name = "TYPBON", length = 2)
public String getTypbon() {
return this.typbon;
}
public void setTypbon(String typbon) {
this.typbon = typbon;
}
@Column(name = "DEBBON", length = 7)
public Date getDebbon() {
return this.debbon;
}
public void setDebbon(Date debbon) {
this.debbon = debbon;
}
@Column(name = "FINBON", length = 7)
public Date getFinbon() {
return this.finbon;
}
public void setFinbon(Date finbon) {
this.finbon = finbon;
}
@Column(name = "NUINEM", length = 7)
public String getNuinem() {
return this.nuinem;
}
public void setNuinem(String nuinem) {
this.nuinem = nuinem;
}
@Column(name = "MOTINI", length = 2)
public String getMotini() {
return this.motini;
}
public void setMotini(String motini) {
this.motini = motini;
}
@Column(name = "MOTFIN", length = 2)
public String getMotfin() {
return this.motfin;
}
public void setMotfin(String motfin) {
this.motfin = motfin;
}
@Column(name = "TIPOCO", length = 1)
public Character getTipoco() {
return this.tipoco;
}
public void setTipoco(Character tipoco) {
this.tipoco = tipoco;
}
@Column(name = "OBSERV", length = 50)
public String getObserv() {
return this.observ;
}
public void setObserv(String observ) {
this.observ = observ;
}
@Column(name = "PERPRU", precision = 2, scale = 0)
public Byte getPerpru() {
return this.perpru;
}
public void setPerpru(Byte perpru) {
this.perpru = perpru;
}
@Column(name = "OBSER2", length = 250)
public String getObser2() {
return this.obser2;
}
public void setObser2(String obser2) {
this.obser2 = obser2;
}
}
i deleted some functions, like hash, equals, etc.
then this is the code that executes de query:
Code:
//field=nudoss, vaue=someBigDecimal
public List<T> genericSearchList(String field, Object value) {
String hql = "from Zyco where " + field + "= :valor";
Query q = getEntityManager().createQuery(hql);
q.setParameter("valor", value);
List<T> result = null;
try {
result = q.getResultList();
} catch (javax.persistence.NoResultException nre) {
//we return null
}
return result;
}
then, the sql executes and, for example, it returns me a List with size 4 (correct), but all elements are null..
can anyone help me, please?
thanks in advance!
PD: i work with Oracle10g Database, and jta datasource