Java Code Examples for org.hibernate.classic.Session#getSession()
The following examples show how to use
org.hibernate.classic.Session#getSession() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiRepresentationTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void testDom4jHQL() { TestData testData = new TestData(); testData.create(); Session session = openSession(); Transaction txn = session.beginTransaction(); org.hibernate.Session dom4j = session.getSession( EntityMode.DOM4J ); List result = dom4j.createQuery( "from Stock" ).list(); assertEquals( "Incorrect result size", 1, result.size() ); Element element = ( Element ) result.get( 0 ); assertEquals( "Something wrong!", testData.stockId, Long.valueOf( element.attributeValue( "id" ) ) ); System.out.println( "**** XML: ****************************************************" ); prettyPrint( element ); System.out.println( "**************************************************************" ); txn.rollback(); session.close(); testData.destroy(); }
Example 2
Source File: MultiRepresentationTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void testDom4jRetreival() { TestData testData = new TestData(); testData.create(); Session session = openSession(); Transaction txn = session.beginTransaction(); org.hibernate.Session dom4j = session.getSession( EntityMode.DOM4J ); Object rtn = dom4j.get( Stock.class.getName(), testData.stockId ); Element element = ( Element ) rtn; assertEquals( "Something wrong!", testData.stockId, Long.valueOf( element.attributeValue( "id" ) ) ); System.out.println( "**** XML: ****************************************************" ); prettyPrint( element ); System.out.println( "**************************************************************" ); Element currVal = element.element( "currentValuation" ); System.out.println( "**** XML: ****************************************************" ); prettyPrint( currVal ); System.out.println( "**************************************************************" ); txn.rollback(); session.close(); testData.destroy(); }
Example 3
Source File: MultiRepresentationTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void testDom4jSave() { TestData testData = new TestData(); testData.create(); Session pojos = openSession(); Transaction txn = pojos.beginTransaction(); org.hibernate.Session dom4j = pojos.getSession( EntityMode.DOM4J ); Element stock = DocumentFactory.getInstance().createElement( "stock" ); stock.addElement( "tradeSymbol" ).setText( "IBM" ); Element val = stock.addElement( "currentValuation" ).addElement( "valuation" ); val.appendContent( stock ); val.addElement( "valuationDate" ).setText( new java.util.Date().toString() ); val.addElement( "value" ).setText( "121.00" ); dom4j.save( Stock.class.getName(), stock ); dom4j.flush(); txn.rollback(); pojos.close(); assertTrue( !pojos.isOpen() ); assertTrue( !dom4j.isOpen() ); prettyPrint( stock ); testData.destroy(); }