Hibernate/config-example

Person.java package events;

import java.util.*;

public class Person {

private Long id; private int age; private String firstname; private String lastname; private Set emailAddresses = new HashSet; private Set events = new HashSet;

public Person {}

public Long getId { return id; }   public void setId(Long id) { this.id = id; }            .....setters and getters for each property etc......

protected Set getEvents { return events; }   protected void setEvents(Set events) { this.events = events; }

} person.hbm.xml mapping file for Person.java  <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



  

     

 hibernate.cfg.xml configuration file.  <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">





org.hsqldb.jdbcDriver <property name="connection.url">jdbc:hsqldb:hsql://localhost <property name="connection.username">sa <property name="connection.password">

<property name="connection.pool_size">1

org.hibernate.dialect.HSQLDialect

<property name="current_session_context_class">thread

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider

<property name="show_sql">true

<property name="hbm2ddl.auto">create

<mapping resource="events/Event.hbm.xml"/> <mapping resource="events/Person.hbm.xml"/>

</session-factory>

</hibernate-configuration>