@@ -0,0 +1,1050 @@
+package session;%0A%0Aimport javax.annotation.PostConstruct;%0Aimport javax.ejb.Singleton;%0Aimport javax.ejb.TransactionManagement;%0Aimport javax.ejb.TransactionManagementType;%0Aimport javax.persistence.EntityManager;%0Aimport javax.persistence.PersistenceContext;%0A%0Aimport domain.Customer;%0Aimport domain.Order;%0A%0A/** Create one of each entity so the database%0A * is %22not null%22 - using /import.sql only works%0A * in Hibernate.%0A * @author ian%0A */%0A@Singleton%0A@TransactionManagement(TransactionManagementType.CONTAINER)%0Apublic class PopulateDatabaseSingletonBean %7B%0A%09%0A%09%09@PersistenceContext(name=%22customer%22) EntityManager customerEntityManager;%0A%09%09@PersistenceContext(name=%22orders%22) EntityManager orderEntityManager;%0A%09%09%0A%09%09@PostConstruct%0A%09%09public void initDB() %7B%0A%09%09%09System.out.println(%22PopulateDatabaseSingletonBean.initCustomerDB()%22);%0A%09%09%09Customer cust = new Customer(%22Idon T'kare%22);%0A%09%09%09customerEntityManager.persist(cust);%0A%09%09%0A%09%09%09System.out.println(%22PopulateDatabaseSingletonBean.initOrdersDB()%22);%0A%09%09%09Order order = new Order();%0A%09%09%09orderEntityManager.persist(order);%0A%09%09%7D%0A%7D%0A

Create an EE6 singleton bean to pre-load the database, since /import.sql is Hibernate-specific, ignored by most. Speaking of ignored, this bean's @PostConstruct annotated methods are ignored, at least by JBoss 6.0.0.20100911-M5.