- Galera estou tentando gerar o schema DDL de minhas classes; não sei se estou esquecendo de alguma coisa, vocês podem me ajudar ?
package com.bdi.util;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import com.bdi.model.endereco.Continente;
public class GerarSchemaDDL {
public static void create(AnnotationConfiguration cfg) {
//new SchemaExport(cfg).create(true, true);
SchemaExport sh = new SchemaExport(cfg);
sh.setOutputFile("c:\\lixo\\postgreSQL_schema_ddl.sql");
sh.setDelimiter(";");
sh.create(false, false);
}
public static void main(String[] args) {
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(com.bdi.model.endereco.Continente.class);
create(cfg);
}
}
// ********** CLASSE PERSISTENCIA **************
package com.bdi.model.endereco;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*/
@Entity
@Table (name="glb_continente", schema="", catalog="")
public abstract class Continente implements Serializable {
private Integer id;
int versao;
private String nome;
//private List<Pais> pais;
public Continente(){}
@Id @GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return id;
}
private void setId(Integer id) {
this.id = id;
}
@Version
@Column(name="versao")
public int getVersao() {
return versao;
}
public void setVersao(int versao) {
this.versao = versao;
}
@Column(name="nme_continente", nullable=false, length=20)
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
- Quando eu executo a classe GerarSchemaDDL dá o seguinte erro:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread “main” java.lang.NoClassDefFoundError: javax/persistence/InheritanceJoinColumns
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:324)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:177)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:594)
at org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:64)
at org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:49)
at com.bdi.util.GerarSchemaDDL.create(GerarSchemaDDL.java:12)
at com.bdi.util.GerarSchemaDDL.main(GerarSchemaDDL.java:23)
-
baixei o hibernate_annotations-3.2.0.cr1, procurei em ejb3-persistence.jar a classe javax.persistence.InheritanceJoinColumns e não encontrei.
-
Onde eu encontro essa classe?
Valeu…