Persistencia com hibernate

pessoal,

fiz os progs abaixo mas na hora de persistir obtenho a seguinte mensagem, e ele nao persiste coisa nenhuma:


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select nextval ('anotacoes.SEQ_UNIVERSIDADE')
Hibernate: select nextval ('anotacoes.SEQ_ENDERECO')

		tx.begin();
		
		Endereco endereco = new Endereco();
		
		endereco.setRua("Av. Senador Salgado Filho");
		endereco.setNumero(1034);
		endereco.setBairro("Logoa Nova");
		endereco.setCidade("Natal");
		endereco.setUf("RN");
		endereco.setCep(59067710);
		
		Universidade universidade = new Universidade();
		universidade.setNome("Universidade Teste");
		
		endereco.setUniversidade(universidade);
		universidade.setEndereco(endereco);
		
		session.save(universidade);

package br.com.dominio;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(schema="anotacoes")
public class Universidade 
{
	@Id
	@SequenceGenerator(name="seqUniversidade", sequenceName="SEQ_UNIVERSIDADE",  allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seqUniversidade")
	@Column(name="id_universidade")
	private int id;
	
	private String nome;
	
	@OneToMany(mappedBy="universidade", fetch = FetchType.LAZY)
	@Cascade(CascadeType.ALL)
	private Collection<Centro> centros;

	@OneToOne(mappedBy="universidade")
	@Cascade(CascadeType.ALL)
	private Endereco endereco;
		
	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the nome
	 */
	public String getNome() {
		return nome;
	}

	/**
	 * @param nome the nome to set
	 */
	public void setNome(String nome) {
		this.nome = nome;
	}

	/**
	 * @return the centros
	 */
	public Collection<Centro> getCentros() {
		return centros;
	}

	/**
	 * @param centros the centros to set
	 */
	public void setCentros(Collection<Centro> centros) {
		this.centros = centros;
	}

	/**
	 * @return the endereco
	 */
	public Endereco getEndereco() {
		return endereco;
	}

	/**
	 * @param endereco the endereco to set
	 */
	public void setEndereco(Endereco endereco) {
		this.endereco = endereco;
	}
}


package br.com.dominio;

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.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(schema="anotacoes")
public class Endereco 
{
	@Id
	@SequenceGenerator(name="seqEndereco", sequenceName="SEQ_ENDERECO", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seqEndereco")
	@Column(name="id_endereco")
	private int id;
	
	private String rua;
	private int numero;
	private String bairro;
	private String cidade;
	private String uf;
	private int cep;
	
	@OneToOne
	@JoinColumn(name="id_universidade")
	private Universidade universidade;
	
	public int getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * @return the rua
	 */
	public String getRua() {
		return rua;
	}
	/**
	 * @param rua the rua to set
	 */
	public void setRua(String rua) {
		this.rua = rua;
	}
	
	/**
	 * @return the numero
	 */
	public int getNumero() {
		return numero;
	}
	/**
	 * @param numero the numero to set
	 */
	public void setNumero(int numero) {
		this.numero = numero;
	}
	
	/**
	 * @return the bairro
	 */
	public String getBairro() {
		return bairro;
	}
	/**
	 * @param bairro the bairro to set
	 */
	public void setBairro(String bairro) {
		this.bairro = bairro;
	}
	
	/**
	 * @return the cidade
	 */
	public String getCidade() {
		return cidade;
	}
	/**
	 * @param cidade the cidade to set
	 */
	public void setCidade(String cidade) {
		this.cidade = cidade;
	}
	
	/**
	 * @return the uf
	 */
	public String getUf() {
		return uf;
	}
	/**
	 * @param uf the uf to set
	 */
	public void setUf(String uf) {
		this.uf = uf;
	}
	
	/**
	 * @return the cep
	 */
	public int getCep() {
		return cep;
	}
	/**
	 * @param cep the cep to set
	 */
	public void setCep(int cep) {
		this.cep = cep;
	}
	
	/**
	 * @return the universidade
	 */
	public Universidade getUniversidade() {
		return universidade;
	}
	/**
	 * @param universidade the universidade to set
	 */
	public void setUniversidade(Universidade universidade) {
		this.universidade = universidade;
	}
}

Olá PePeLeGaL
Então rapaz… não sei muito bem se é isso, mas esta parecendo que seja sua anotação
tenta fazer assim nestas linhas :

@Entity
@Table(name = "universidade")
public class Universidade  { 
    @Id   
    @GeneratedValue() 
    @Column(name="id_universidade", unique = true, nullable = false)   
    private int id; 
    ...... 
}   

@Entity
@Table(name = "endereco")   
public class Endereco   
{   
    @Id   
    @GeneratedValue() 
    @Column(name="id_endereco", unique = true, nullable = false)   
    private int id;   
 }
   Tem como você gerar essas classes anotadas facilmente através do hibernate tools [url]www.hibernate.org[/url]

flwsss…
espero ter ajudado

ola pepe

voce nao esta esquecendo de chamar o commit da transacao?

se nao for isso, coloque a saida do log pra gente…

desculpe a demora para responder

thiago.filadelfo,
adicionei as funcionalidades que voce sugeriu nas anotacoes mas nao adiantou.

Paulo Silveira,
como a natureza eh perfeita. :lol: apenas adicionei o commit, como voce sugeriu e funcionou perfeitamente. Valeu :wink: