Hibernate não mostra registros com valores nulos [resolvido]

3 respostas
FkJ

Sou iniciante em Hibernate. Estou usando a versão 3.2.2 GA + Hibernate Annotations 3.2.1 GA + Hibernate EntityManager 3.2.1 GA. Quando executo uma query, a quantidade de registros encontrada está correta, mas os objetos correspondentes a resgistros com valor nulo não são mostrados, é como se ele fossem anulados. Executando o debug eles aparecem como nulo na lista. Basta ter apenas um valor nulo no registro para isso acontecer. O mapeamento foi gerado com o Hibernate Tools 3.2 beta 9.

Segue abaixo saída no console e o mapeamento da tabela em questão(que foi dividido em dois arquivos). Qualquer ajuda é bem vinda.

Obrigado,
Felipe

16/02/2007 09:20:43 org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.2.1.GA
16/02/2007 09:20:43 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.2.1.GA
16/02/2007 09:20:43 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.2
16/02/2007 09:20:43 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
16/02/2007 09:20:43 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
16/02/2007 09:20:43 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
16/02/2007 09:20:45 org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: br.com.spdata.hibernate.Sctecnic
16/02/2007 09:20:45 org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity br.com.spdata.hibernate.Sctecnic on table SCTECNIC
16/02/2007 09:20:46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
16/02/2007 09:20:46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
16/02/2007 09:20:46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: true
16/02/2007 09:20:46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.firebirdsql.jdbc.FBDriver at URL: jdbc:firebirdsql:192.168.1.7:/bancos/spdata.gdb
16/02/2007 09:20:46 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=SYSDBA, password=****, autocommit=true, release_mode=auto}
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: Firebird 1.51LI-V1.5.3.4870 Firebird 1.5/tcp (fkj-desktop)/P10, version: LI-V1.5.3.4870 Firebird 1.51LI-V1.5.3.4870 Firebird 1.5/tcp (fkj-desktop)/P10
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: Jaybird JCA/JDBC driver, version: 2.1
16/02/2007 09:20:46 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.FirebirdDialect
16/02/2007 09:20:46 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
16/02/2007 09:20:46 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16/02/2007 09:20:46 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: enabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
16/02/2007 09:20:46 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
16/02/2007 09:20:46 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
16/02/2007 09:20:47 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Hibernate: select sctecnic0_.COD as COD0_, sctecnic0_.NOME as NOME0_, sctecnic0_.IMPLANTACAO as IMPLANTA3_0_, sctecnic0_.SETOR as SETOR0_, sctecnic0_.ATIVO as ATIVO0_, sctecnic0_.FAZ_PS as FAZ6_0_, sctecnic0_.DIA_ANIVERSARIO as DIA7_0_, sctecnic0_.MES_ANIVERSARIO as MES8_0_, sctecnic0_.SENHA as SENHA0_, sctecnic0_.EMAIL as EMAIL0_, sctecnic0_.RAMAL as RAMAL0_, sctecnic0_.CELULAR as CELULAR0_, sctecnic0_.IP as IP0_, sctecnic0_.DATA_BACKUP as DATA14_0_, sctecnic0_.REGIAO as REGIAO0_, sctecnic0_.CRIPTO as CRIPTO0_, sctecnic0_.MES_FIN as MES17_0_, sctecnic0_.ANO_FIN as ANO18_0_, sctecnic0_.ATUALIZA as ATUALIZA0_, sctecnic0_.ITEM_DESP as ITEM20_0_, sctecnic0_.UF as UF0_, sctecnic0_.REPRES as REPRES0_ from SCTECNIC sctecnic0_ order by sctecnic0_.NOME
total:191
16/02/2007 09:20:48 org.hibernate.impl.SessionFactoryImpl close
INFO: closing
16/02/2007 09:20:48 org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:firebirdsql:192.168.1.7:/bancos/spdata.gdb
package br.com.spdata.hibernate;

// Generated 15/02/2007 11:13:20 by Hibernate Tools 3.2.0.b9
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Sctecnic generated by hbm2java
 */
@Entity
@Table(name = "SCTECNIC", uniqueConstraints = @UniqueConstraint(columnNames = "COD"))
public class Sctecnic implements java.io.Serializable
{
	private static final long	serialVersionUID	= 7040672788419190097L;
	private SctecnicId	id;

	public Sctecnic()
	{
	}

	public Sctecnic(SctecnicId id)
	{
		this.id = id;
	}

	@EmbeddedId
	@AttributeOverrides( {@AttributeOverride(name = "cod", column = @Column(name = "COD", unique = true)),
			@AttributeOverride(name = "nome", column = @Column(name = "NOME", length = 40)),
			@AttributeOverride(name = "implantacao", column = @Column(name = "IMPLANTACAO", length = 1)),
			@AttributeOverride(name = "setor", column = @Column(name = "SETOR")),
			@AttributeOverride(name = "ativo", column = @Column(name = "ATIVO", length = 1)),
			@AttributeOverride(name = "fazPs", column = @Column(name = "FAZ_PS", length = 1)),
			@AttributeOverride(name = "diaAniversario", column = @Column(name = "DIA_ANIVERSARIO")),
			@AttributeOverride(name = "mesAniversario", column = @Column(name = "MES_ANIVERSARIO")),
			@AttributeOverride(name = "senha", column = @Column(name = "SENHA", length = 40)),
			@AttributeOverride(name = "email", column = @Column(name = "EMAIL", length = 40)),
			@AttributeOverride(name = "ramal", column = @Column(name = "RAMAL", length = 4)),
			@AttributeOverride(name = "celular", column = @Column(name = "CELULAR", length = 14)),
			@AttributeOverride(name = "ip", column = @Column(name = "IP", length = 15)),
			@AttributeOverride(name = "dataBackup", column = @Column(name = "DATA_BACKUP", length = 10)),
			@AttributeOverride(name = "regiao", column = @Column(name = "REGIAO")),
			@AttributeOverride(name = "cripto", column = @Column(name = "CRIPTO", length = 1)),
			@AttributeOverride(name = "mesFin", column = @Column(name = "MES_FIN")),
			@AttributeOverride(name = "anoFin", column = @Column(name = "ANO_FIN")),
			@AttributeOverride(name = "atualiza", column = @Column(name = "ATUALIZA", length = 1)),
			@AttributeOverride(name = "itemDesp", column = @Column(name = "ITEM_DESP")),
			@AttributeOverride(name = "uf", column = @Column(name = "UF", length = 2)),
			@AttributeOverride(name = "repres", column = @Column(name = "REPRES"))})
	public SctecnicId getId()
	{
		return this.id;
	}

	public void setId(SctecnicId id)
	{
		this.id = id;
	}
}
package br.com.spdata.hibernate;

// Generated 15/02/2007 11:13:20 by Hibernate Tools 3.2.0.b9
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * SctecnicId generated by hbm2java
 */
@Embeddable
public class SctecnicId implements java.io.Serializable
{
	private static final long	serialVersionUID	= 5435628004922078042L;
	private Short		cod;
	private String		nome;
	private Character	implantacao;
	private Short		setor;
	private Character	ativo;
	private Character	fazPs;
	private Short		diaAniversario;
	private Short		mesAniversario;
	private String		senha;
	private String		email;
	private String		ramal;
	private String		celular;
	private String		ip;
	private Date		dataBackup;
	private Short		regiao;
	private String		cripto;
	private Short		mesFin;
	private Short		anoFin;
	private Character	atualiza;
	private Short		itemDesp;
	private String		uf;
	private Short		repres;

	public SctecnicId()
	{
	}

	public SctecnicId(Short cod, String nome, Character implantacao, Short setor, Character ativo, Character fazPs,
			Short diaAniversario, Short mesAniversario, String senha, String email, String ramal, String celular,
			String ip, Date dataBackup, Short regiao, String cripto, Short mesFin, Short anoFin, Character atualiza,
			Short itemDesp, String uf, Short repres)
	{
		this.cod = cod;
		this.nome = nome;
		this.implantacao = implantacao;
		this.setor = setor;
		this.ativo = ativo;
		this.fazPs = fazPs;
		this.diaAniversario = diaAniversario;
		this.mesAniversario = mesAniversario;
		this.senha = senha;
		this.email = email;
		this.ramal = ramal;
		this.celular = celular;
		this.ip = ip;
		this.dataBackup = dataBackup;
		this.regiao = regiao;
		this.cripto = cripto;
		this.mesFin = mesFin;
		this.anoFin = anoFin;
		this.atualiza = atualiza;
		this.itemDesp = itemDesp;
		this.uf = uf;
		this.repres = repres;
	}

	@Column(name = "COD", unique = true)
	public Short getCod()
	{
		return this.cod;
	}

	public void setCod(Short cod)
	{
		this.cod = cod;
	}

	@Column(name = "NOME", length = 40)
	public String getNome()
	{
		return this.nome;
	}

	public void setNome(String nome)
	{
		this.nome = nome;
	}

	@Column(name = "IMPLANTACAO", length = 1)
	public Character getImplantacao()
	{
		return this.implantacao;
	}

	public void setImplantacao(Character implantacao)
	{
		this.implantacao = implantacao;
	}

	@Column(name = "SETOR")
	public Short getSetor()
	{
		return this.setor;
	}

	public void setSetor(Short setor)
	{
		this.setor = setor;
	}

	@Column(name = "ATIVO", length = 1)
	public Character getAtivo()
	{
		return this.ativo;
	}

	public void setAtivo(Character ativo)
	{
		this.ativo = ativo;
	}

	@Column(name = "FAZ_PS", length = 1)
	public Character getFazPs()
	{
		return this.fazPs;
	}

	public void setFazPs(Character fazPs)
	{
		this.fazPs = fazPs;
	}

	@Column(name = "DIA_ANIVERSARIO")
	public Short getDiaAniversario()
	{
		return this.diaAniversario;
	}

	public void setDiaAniversario(Short diaAniversario)
	{
		this.diaAniversario = diaAniversario;
	}

	@Column(name = "MES_ANIVERSARIO")
	public Short getMesAniversario()
	{
		return this.mesAniversario;
	}

	public void setMesAniversario(Short mesAniversario)
	{
		this.mesAniversario = mesAniversario;
	}

	@Column(name = "SENHA", length = 40)
	public String getSenha()
	{
		return this.senha;
	}

	public void setSenha(String senha)
	{
		this.senha = senha;
	}

	@Column(name = "EMAIL", length = 40)
	public String getEmail()
	{
		return this.email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	@Column(name = "RAMAL", length = 4)
	public String getRamal()
	{
		return this.ramal;
	}

	public void setRamal(String ramal)
	{
		this.ramal = ramal;
	}

	@Column(name = "CELULAR", length = 14)
	public String getCelular()
	{
		return this.celular;
	}

	public void setCelular(String celular)
	{
		this.celular = celular;
	}

	@Column(name = "IP", length = 15)
	public String getIp()
	{
		return this.ip;
	}

	public void setIp(String ip)
	{
		this.ip = ip;
	}

	@Column(name = "DATA_BACKUP", length = 10)
	public Date getDataBackup()
	{
		return this.dataBackup;
	}

	public void setDataBackup(Date dataBackup)
	{
		this.dataBackup = dataBackup;
	}

	@Column(name = "REGIAO")
	public Short getRegiao()
	{
		return this.regiao;
	}

	public void setRegiao(Short regiao)
	{
		this.regiao = regiao;
	}

	@Column(name = "CRIPTO", length = 1)
	public String getCripto()
	{
		return this.cripto;
	}

	public void setCripto(String cripto)
	{
		this.cripto = cripto;
	}

	@Column(name = "MES_FIN")
	public Short getMesFin()
	{
		return this.mesFin;
	}

	public void setMesFin(Short mesFin)
	{
		this.mesFin = mesFin;
	}

	@Column(name = "ANO_FIN")
	public Short getAnoFin()
	{
		return this.anoFin;
	}

	public void setAnoFin(Short anoFin)
	{
		this.anoFin = anoFin;
	}

	@Column(name = "ATUALIZA", length = 1)
	public Character getAtualiza()
	{
		return this.atualiza;
	}

	public void setAtualiza(Character atualiza)
	{
		this.atualiza = atualiza;
	}

	@Column(name = "ITEM_DESP")
	public Short getItemDesp()
	{
		return this.itemDesp;
	}

	public void setItemDesp(Short itemDesp)
	{
		this.itemDesp = itemDesp;
	}

	@Column(name = "UF", length = 2)
	public String getUf()
	{
		return this.uf;
	}

	public void setUf(String uf)
	{
		this.uf = uf;
	}

	@Column(name = "REPRES")
	public Short getRepres()
	{
		return this.repres;
	}

	public void setRepres(Short repres)
	{
		this.repres = repres;
	}

	public boolean equals(Object other)
	{
		if((this == other)) return true;
		if((other == null)) return false;
		if(!(other instanceof SctecnicId)) return false;
		SctecnicId castOther = (SctecnicId) other;
		return ((this.getCod() == castOther.getCod()) || (this.getCod() != null && castOther.getCod() != null && this
				.getCod().equals(castOther.getCod())))
				&& ((this.getNome() == castOther.getNome()) || (this.getNome() != null && castOther.getNome() != null && this
						.getNome().equals(castOther.getNome())))
				&& ((this.getImplantacao() == castOther.getImplantacao()) || (this.getImplantacao() != null
						&& castOther.getImplantacao() != null && this.getImplantacao()
						.equals(castOther.getImplantacao())))
				&& ((this.getSetor() == castOther.getSetor()) || (this.getSetor() != null
						&& castOther.getSetor() != null && this.getSetor().equals(castOther.getSetor())))
				&& ((this.getAtivo() == castOther.getAtivo()) || (this.getAtivo() != null
						&& castOther.getAtivo() != null && this.getAtivo().equals(castOther.getAtivo())))
				&& ((this.getFazPs() == castOther.getFazPs()) || (this.getFazPs() != null
						&& castOther.getFazPs() != null && this.getFazPs().equals(castOther.getFazPs())))
				&& ((this.getDiaAniversario() == castOther.getDiaAniversario()) || (this.getDiaAniversario() != null
						&& castOther.getDiaAniversario() != null && this.getDiaAniversario().equals(
						castOther.getDiaAniversario())))
				&& ((this.getMesAniversario() == castOther.getMesAniversario()) || (this.getMesAniversario() != null
						&& castOther.getMesAniversario() != null && this.getMesAniversario().equals(
						castOther.getMesAniversario())))
				&& ((this.getSenha() == castOther.getSenha()) || (this.getSenha() != null
						&& castOther.getSenha() != null && this.getSenha().equals(castOther.getSenha())))
				&& ((this.getEmail() == castOther.getEmail()) || (this.getEmail() != null
						&& castOther.getEmail() != null && this.getEmail().equals(castOther.getEmail())))
				&& ((this.getRamal() == castOther.getRamal()) || (this.getRamal() != null
						&& castOther.getRamal() != null && this.getRamal().equals(castOther.getRamal())))
				&& ((this.getCelular() == castOther.getCelular()) || (this.getCelular() != null
						&& castOther.getCelular() != null && this.getCelular().equals(castOther.getCelular())))
				&& ((this.getIp() == castOther.getIp()) || (this.getIp() != null && castOther.getIp() != null && this
						.getIp().equals(castOther.getIp())))
				&& ((this.getDataBackup() == castOther.getDataBackup()) || (this.getDataBackup() != null
						&& castOther.getDataBackup() != null && this.getDataBackup().equals(castOther.getDataBackup())))
				&& ((this.getRegiao() == castOther.getRegiao()) || (this.getRegiao() != null
						&& castOther.getRegiao() != null && this.getRegiao().equals(castOther.getRegiao())))
				&& ((this.getCripto() == castOther.getCripto()) || (this.getCripto() != null
						&& castOther.getCripto() != null && this.getCripto().equals(castOther.getCripto())))
				&& ((this.getMesFin() == castOther.getMesFin()) || (this.getMesFin() != null
						&& castOther.getMesFin() != null && this.getMesFin().equals(castOther.getMesFin())))
				&& ((this.getAnoFin() == castOther.getAnoFin()) || (this.getAnoFin() != null
						&& castOther.getAnoFin() != null && this.getAnoFin().equals(castOther.getAnoFin())))
				&& ((this.getAtualiza() == castOther.getAtualiza()) || (this.getAtualiza() != null
						&& castOther.getAtualiza() != null && this.getAtualiza().equals(castOther.getAtualiza())))
				&& ((this.getItemDesp() == castOther.getItemDesp()) || (this.getItemDesp() != null
						&& castOther.getItemDesp() != null && this.getItemDesp().equals(castOther.getItemDesp())))
				&& ((this.getUf() == castOther.getUf()) || (this.getUf() != null && castOther.getUf() != null && this
						.getUf().equals(castOther.getUf())))
				&& ((this.getRepres() == castOther.getRepres()) || (this.getRepres() != null
						&& castOther.getRepres() != null && this.getRepres().equals(castOther.getRepres())));
	}

	public int hashCode()
	{
		int result = 17;
		result = 37 * result + (getCod() == null ? 0 : this.getCod().hashCode());
		result = 37 * result + (getNome() == null ? 0 : this.getNome().hashCode());
		result = 37 * result + (getImplantacao() == null ? 0 : this.getImplantacao().hashCode());
		result = 37 * result + (getSetor() == null ? 0 : this.getSetor().hashCode());
		result = 37 * result + (getAtivo() == null ? 0 : this.getAtivo().hashCode());
		result = 37 * result + (getFazPs() == null ? 0 : this.getFazPs().hashCode());
		result = 37 * result + (getDiaAniversario() == null ? 0 : this.getDiaAniversario().hashCode());
		result = 37 * result + (getMesAniversario() == null ? 0 : this.getMesAniversario().hashCode());
		result = 37 * result + (getSenha() == null ? 0 : this.getSenha().hashCode());
		result = 37 * result + (getEmail() == null ? 0 : this.getEmail().hashCode());
		result = 37 * result + (getRamal() == null ? 0 : this.getRamal().hashCode());
		result = 37 * result + (getCelular() == null ? 0 : this.getCelular().hashCode());
		result = 37 * result + (getIp() == null ? 0 : this.getIp().hashCode());
		result = 37 * result + (getDataBackup() == null ? 0 : this.getDataBackup().hashCode());
		result = 37 * result + (getRegiao() == null ? 0 : this.getRegiao().hashCode());
		result = 37 * result + (getCripto() == null ? 0 : this.getCripto().hashCode());
		result = 37 * result + (getMesFin() == null ? 0 : this.getMesFin().hashCode());
		result = 37 * result + (getAnoFin() == null ? 0 : this.getAnoFin().hashCode());
		result = 37 * result + (getAtualiza() == null ? 0 : this.getAtualiza().hashCode());
		result = 37 * result + (getItemDesp() == null ? 0 : this.getItemDesp().hashCode());
		result = 37 * result + (getUf() == null ? 0 : this.getUf().hashCode());
		result = 37 * result + (getRepres() == null ? 0 : this.getRepres().hashCode());
		return result;
	}
}

3 Respostas

plentz

Pelamordedeus, tua classe ID tem todos os campos da tabela? Por acaso é um PK mega-composta?!

FkJ

O problema está nessa tabela mesmo, gerei o mapeamanto de outra tabela que também contém vários registros com valores nulos e funcionou perfeitamente. Provavelmente deve ser por causa disso: “Nullable foreign keys are not considered good practice in traditional data modelling, so all our examples use not null foreign keys. This is not a requirement of Hibernate, and the mappings will all work if you drop the nullability constraints.” http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#associations

Segue o DDL para análise

DDL da tabela

CREATE TABLE SCTECNIC(
  COD Smallint,
  NOME Varchar(40),
  IMPLANTACAO Char(1) DEFAULT 'F',
  SETOR Smallint DEFAULT 0,
  ATIVO Char(1) DEFAULT 'T',
  FAZ_PS Char(1) DEFAULT 'F',
  DIA_ANIVERSARIO Smallint DEFAULT 0,
  MES_ANIVERSARIO Smallint DEFAULT 0,
  SENHA Varchar(40) DEFAULT 0,
  EMAIL Varchar(40) DEFAULT '',
  RAMAL Varchar(4),
  CELULAR Varchar(14),
  IP Varchar(15),
  DATA_BACKUP Date DEFAULT '12/30/1899',
  REGIAO Smallint DEFAULT 0,
  CRIPTO Varchar(1) DEFAULT 'F',
  MES_FIN Smallint DEFAULT 0,
  ANO_FIN Smallint DEFAULT 0,
  ATUALIZA Char(1) DEFAULT 'F',
  ITEM_DESP Smallint DEFAULT 0,
  UF Varchar(2) DEFAULT 'MG',
  REPRES Smallint DEFAULT 0
);
ALTER TABLE SCTECNIC ADD CONSTRAINT FK_SCTECNIC_0
  FOREIGN KEY (SETOR) REFERENCES SCSETOR (COD);
CREATE UNIQUE INDEX SCTECNIC0 ON SCTECNIC (COD);
GRANT DELETE, INSERT, REFERENCES, SELECT, UPDATE
 ON SCTECNIC TO  SYSDBA WITH GRANT OPTION;
FkJ

Resolvido. O problema era que a tabela não tinha PK, portanto o Hibernate considerava a tabela toda como PK na hora de fazer o mapeamento, e como a tabela toda era PK registros com valores nulos não eram retornados nas consultas.

Criado 16 de fevereiro de 2007
Ultima resposta 18 de fev. de 2007
Respostas 3
Participantes 2