Pessoal,
Estou usando pela primeira vez hibernate. Existe alguma ferramenta que gere automaticamente o mapeamento das tabelas do BD para o XML que o hibernate utiliza (arquivos.hbm.xml)
obrigado
Victor
Pessoal,
Estou usando pela primeira vez hibernate. Existe alguma ferramenta que gere automaticamente o mapeamento das tabelas do BD para o XML que o hibernate utiliza (arquivos.hbm.xml)
obrigado
Victor
Pessoal,Estou usando pela primeira vez hibernate. Existe alguma ferramenta que gere automaticamente o mapeamento das tabelas do BD para o XML que o hibernate utiliza (arquivos.hbm.xml)
obrigado
Victor
Victor,
Passe a usar Annotations deixe os XMLs de configuração para lá.
Olá tem uma ferramenta que gera xml e os annotations
ela chama HibernateTools… é um plugin do eclipse… muito bom
Espero ter ajudado
Flwsss
Mesmo com essas ferramentos… é recomendavel que use o Annotations… é tudo na classe e voce tem mais controle.
Sim… é o futuro
Sai os xml, pq custa um pouco ficar parseando, o annotations é mais rápido e
melhor por oferecer mais recurso…
Só para se ter uma idéia com o EJB 3.1, só irá ter anotações… daqui a pouco vc
nem vai mais programar if se o objeto for null ou branco faça isso… a anotação vai
cuidar disto. srsrsr É uma coisa poderosa!!!
Flwsss…
Como o pessoal disse, mude para annotations. Eu uso JPA, e se vc for usar, olhá aí um exemplo de arquivo de configuração para que o banco seja gerado automaticamente:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="lebarone">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
<property name="hibernate.connection.url" value="jdbc:postgresql:lebarone://localhost" />
<property name="hibernate.connection.username" value="postgres" />
<property name="hibernate.connection.password" value="2505" />
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
</persistence>
A linha do código:
@Entity
public class Cliente implements Codificavel {
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long codigo;
@Column(nullable=false,length=50)
private String nome;
@Column(nullable=false,length=50)
private String nomeNormalizado;
@Column(length=300)
private String sobrenome;
@Column(length=300)
private String sobrenomeNormalizado;
@Column(length=512)
private String enderecoResidencial;
@Column(length=9)
private String cepResidencial;
@Column(length=512)
private String enderecoComercial;
@Column(length=14)
private String tel;
@Column(length=14)
private String tel2;
@Column(length=14)
private String telComercial;
private String ramal;
private String nextel;
@Column(length=14)
private String cel;
@Column(length=64)
private String mail;
@Column(length=2048)
private String anotacao;
@Temporal(TemporalType.DATE)
private Date dataPagamento;
@Column(nullable = false, precision = 15, scale = 2)
private BigDecimal valorDevido;
@OneToMany(mappedBy="cliente",cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
private Collection<Pagamento> pagamentos=new ArrayList<Pagamento>();
// a seguir métodos getters e setters
Espero ter ajudado