O @Version nao pode estar dentro de uma classe @Embedded?

1 resposta
T

Pessoal, estou aqui implementando um projeto pra estudos e me ocorreu um erro estranho, que eu nao estou compreendendo direito…

eu tenho uma classe para onde eu defino os campos que serao usadas em todas as tabelas:

@Embeddable
public class ControleHistoricoEVersao {

	@Temporal(TemporalType.DATE)
	@Column(name="dt_alteracao", nullable=false)
	private Calendar dtAlteracao;

	@Temporal(TemporalType.DATE)
	@Column(name="dt_inclusao", nullable=false)
	private Calendar dtInclusao;
	
	@Column(nullable=false)
	private int status;
	
	@Version
	private Integer versao;

//getter e setters
}

e em outra classe eu declaro eles la:

@Entity
public class Usuario {

	@Id
	@GeneratedValue
	private Long id;
	
	@Column(length=255, nullable=false)
	private String nome;
	
	@Column(length=50, nullable=false)
	private String senha;
	
	@Column(length=50, nullable=false)
	private String login;
	
	private ControleHistoricoEVersao controleHistoricoEVersao;
}

porem ao criar o banco atraves do SchemaExport ele me retorna esse erro:

Exception in thread "main" org.hibernate.AnnotationException: Unable to define @Version on an embedded class: projetoTeste.entidade.ControleHistoricoEVersao
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1310)
	at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1834)
	at org.hibernate.cfg.AnnotationBinder.bindComponent(AnnotationBinder.java:1768)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1630)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
	at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:789)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
	at projetoTeste.util.GeraBanco.main(GeraBanco.java:12)

alguem sabe o q pode estar acontecendo ?

1 Resposta

T

alguem ?

Criado 20 de dezembro de 2009
Ultima resposta 21 de dez. de 2009
Respostas 1
Participantes 1