Code example for Session

Methods: createSQLQuery

0
		// We need first to modify the columns in the middle (join table) to 
		// allow null values. Hbm2ddl doesn't seem 
		// to allow this. 
		em.getTransaction().begin();
		Session session = (Session) em.getDelegate();
		session.createSQLQuery("DROP TABLE children").executeUpdate();
		session
				.createSQLQuery(
						"CREATE TABLE children(parent_id integer, child1_id integer NULL, child2_id integer NULL)") 
				.executeUpdate();
		session.createSQLQuery("DROP TABLE children_AUD").executeUpdate();
		session
				.createSQLQuery(
						"CREATE TABLE children_AUD(REV integer NOT NULL, REVEND integer, " 
								+ revendTimestampColumName
								+ " timestamp, REVTYPE tinyint, " 
								+ "parent_id integer, child1_id integer NULL, child2_id integer NULL)") 
				.executeUpdate();
		em.getTransaction().commit();
		em.clear();
Contextual code suggestions in your IDE  Get Codota for Java