/////////////////////////////////////////////////////////////////////////
import java.util.Date;
import java.util.List;
import org.hibernate.*;
import org.hibernate.criterion.*;
public class SimpleRetrieveTest {
public static void main(String[] args) {
HibernateUtil.setup("create table A ( id int);");
HibernateUtil.setup("create table B ( id int, aid int);");
// hibernate code start
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
A a = new A();
B b1 = new B();
B b2 = new B();
a.setBs( new B[] {b1, b2} );
session.save(a);
tx.commit();
HibernateUtil.closeSession();
HibernateUtil.sessionFactory.close();
// hibernate code end
HibernateUtil.checkData("select * from A");
HibernateUtil.checkData("select * from B");
}
}
/////////////////////////////////////////////////////////////////////////
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
/////////////////////////////////////////////////////////////////////////
/**
* @author Emmanuel Bernard
*/
public class A {
private Integer id;
private B[] bs;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public B[] getBs() {
return bs;
}
public void setBs(B[] bs) {
this.bs = bs;
}
}
/////////////////////////////////////////////////////////////////////////
/**
* @author Emmanuel Bernard
*/
public class B {
private Integer id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
/////////////////////////////////////////////////////////////////////////
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
org.hsqldb.jdbcDriver
jdbc:hsqldb:data/tutorial
sa
1
org.hibernate.dialect.HSQLDialect
true
/////////////////////////////////////////////////////////////////////////
HibernateMapArrayForOneToManyMap.zip( 4,578 k)