本文整理汇总了Java中org.hibernate.util.SerializationHelper.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationHelper.deserialize方法的具体用法?Java SerializationHelper.deserialize怎么用?Java SerializationHelper.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.util.SerializationHelper
的用法示例。
在下文中一共展示了SerializationHelper.deserialize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testManualDisconnectChain
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
/**
* Test that the legacy manual disconnect()/reconnect() chain works as
* expected in the given environment.
*
* @throws Throwable
*/
public final void testManualDisconnectChain() throws Throwable {
prepare();
Session sessionUnderTest = getSessionUnderTest();
sessionUnderTest.disconnect();
byte[] bytes = SerializationHelper.serialize( sessionUnderTest );
checkSerializedState( sessionUnderTest );
Session s2 = ( Session ) SerializationHelper.deserialize( bytes );
checkDeserializedState( s2 );
reconnect( s2 );
s2.disconnect();
reconnect( s2 );
release( sessionUnderTest );
release( s2 );
done();
}
示例2: loadSessionQueryBagFromDB
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
public static SessionQueryBag loadSessionQueryBagFromDB(HttpSession session , Long userId){
SessionQueryBag queryBag = null;
UserQuery userQuery = null;
if(userId != null){
userQuery = myListLoader.loadUserQuery(userId);
if(userQuery != null && userQuery.getQueryContent()!= null){
session.setAttribute(RembrandtConstants.USER_QUERY, userQuery);
byte[] objectData = userQuery.getQueryContent();
Object obj = null;
try {
obj = SerializationHelper.deserialize(objectData);
if(obj != null && obj instanceof SessionQueryBag){
queryBag = (SessionQueryBag)obj;
}
} catch (SerializationException e) {
System.out.println(e);
logger.error(e.getMessage());
session.removeAttribute(RembrandtConstants.USER_QUERY);
}
}else{
session.removeAttribute(RembrandtConstants.USER_QUERY);
}
}
return queryBag;
}
示例3: testAggressiveReleaseWithExplicitDisconnectReconnect
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
public void testAggressiveReleaseWithExplicitDisconnectReconnect() throws Exception {
DummyTransactionManager.INSTANCE.begin();
Session s = getSessions().getCurrentSession();
s.createQuery( "from Item" ).list();
s.disconnect();
byte[] bytes = SerializationHelper.serialize( s );
s = ( Session ) SerializationHelper.deserialize( bytes );
s.reconnect();
s.createQuery( "from Item" ).list();
DummyTransactionManager.INSTANCE.getTransaction().commit();
}
示例4: testProxyArray
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
public void testProxyArray() throws Exception {
Session s = openSession();
GlarchProxy g = new Glarch();
Glarch g1 = new Glarch();
Glarch g2 = new Glarch();
g.setProxyArray( new GlarchProxy[] { g1, g2 } );
Glarch g3 = new Glarch();
s.save(g3);
g2.setProxyArray( new GlarchProxy[] {null, g3, g} );
Set set = new HashSet();
set.add(g1);
set.add(g2);
g.setProxySet(set);
s.save(g);
s.save(g1);
s.save(g2);
Serializable id = s.getIdentifier(g);
s.flush();
s.connection().commit();
s.close();
s = openSession();
g = (GlarchProxy) s.load(Glarch.class, id);
assertTrue( "array of proxies", g.getProxyArray().length==2 );
assertTrue( "array of proxies", g.getProxyArray()[0]!=null );
assertTrue("deferred load test",g.getProxyArray()[1].getProxyArray()[0]==null );
assertTrue("deferred load test",g.getProxyArray()[1].getProxyArray()[2]==g );
assertTrue( "set of proxies", g.getProxySet().size()==2 );
Iterator iter = s.iterate("from Glarch g");
while ( iter.hasNext() ) {
iter.next();
iter.remove();
}
s.flush();
s.connection().commit();
s.disconnect();
SerializationHelper.deserialize( SerializationHelper.serialize(s) );
s.close();
}
示例5: testDetachedCriteria
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
public void testDetachedCriteria() {
DetachedCriteria dc = DetachedCriteria.forClass(Student.class)
.add( Property.forName("name").eq("Gavin King") )
.addOrder( Order.asc("studentNumber") )
.setProjection( Property.forName("studentNumber") );
byte[] bytes = SerializationHelper.serialize(dc);
dc = (DetachedCriteria) SerializationHelper.deserialize(bytes);
Session session = openSession();
Transaction t = session.beginTransaction();
Student gavin = new Student();
gavin.setName("Gavin King");
gavin.setStudentNumber(232);
Student bizarroGavin = new Student();
bizarroGavin.setName("Gavin King");
bizarroGavin.setStudentNumber(666);
session.persist(bizarroGavin);
session.persist(gavin);
List result = dc.getExecutableCriteria(session)
.setMaxResults(3)
.list();
assertEquals( result.size(), 2 );
assertEquals( result.get(0), new Long(232) );
assertEquals( result.get(1), new Long(666) );
session.delete(gavin);
session.delete(bizarroGavin);
t.commit();
session.close();
}
示例6: fromBytes
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
private static Object fromBytes(byte[] bytes) throws SerializationException
{
return SerializationHelper.deserialize(bytes);
}
示例7: fromBytes
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
private static Object fromBytes( byte[] bytes ) throws SerializationException {
return SerializationHelper.deserialize(bytes);
}
示例8: testUpdate
import org.hibernate.util.SerializationHelper; //导入方法依赖的package包/类
public void testUpdate() throws Exception {
Session s = openSession();
Foo foo = new Foo();
s.save(foo);
s.flush();
s.connection().commit();
s.close();
foo = (Foo) SerializationHelper.deserialize( SerializationHelper.serialize(foo) );
s = openSession();
FooProxy foo2 = (FooProxy) s.load( Foo.class, foo.getKey() );
foo2.setString("dirty");
foo2.setBoolean( new Boolean(false) );
foo2.setBytes( new byte[] { 1,2,3} );
foo2.setDate(null);
foo2.setShort( new Short("69") );
s.flush();
s.connection().commit();
s.close();
s = openSession();
foo2.setString("dirty again");
s.update(foo2);
s.flush();
s.connection().commit();
s.close();
s = openSession();
foo2.setString("dirty again 2");
s.update(foo2);
s.flush();
s.connection().commit();
s.close();
s = openSession();
Foo foo3 = new Foo();
s.load( foo3, foo.getKey() );
// There is an interbase bug that causes null integers to return as 0, also numeric precision is <= 15
assertTrue( "update", foo2.equalsFoo(foo3) );
s.delete(foo3);
s.delete("from Glarch");
s.flush();
s.connection().commit();
s.close();
}