本文整理汇总了Java中org.hibernate.StatelessSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Java StatelessSession.delete方法的具体用法?Java StatelessSession.delete怎么用?Java StatelessSession.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.StatelessSession
的用法示例。
在下文中一共展示了StatelessSession.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRefresh
import org.hibernate.StatelessSession; //导入方法依赖的package包/类
public void testRefresh() {
StatelessSession ss = getSessions().openStatelessSession();
Transaction tx = ss.beginTransaction();
Paper paper = new Paper();
paper.setColor( "whtie" );
ss.insert( paper );
tx.commit();
ss.close();
ss = getSessions().openStatelessSession();
tx = ss.beginTransaction();
Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() );
p2.setColor( "White" );
ss.update( p2 );
tx.commit();
ss.close();
ss = getSessions().openStatelessSession();
tx = ss.beginTransaction();
assertEquals( "whtie", paper.getColor() );
ss.refresh( paper );
assertEquals( "White", paper.getColor() );
ss.delete( paper );
tx.commit();
ss.close();
}
示例2: executeRemoveIfExists
import org.hibernate.StatelessSession; //导入方法依赖的package包/类
private void executeRemoveIfExists(StatelessSession session, BulkItem bulkItem) {
Object entry = bulkItem.getItem();
if (exists(bulkItem, session)) {
if (logger.isTraceEnabled()) {
logger.trace("[Exists REMOVE] Deleting Entry [" + entry + "]");
}
session.delete(entry);
}
}
示例3: executeRemove
import org.hibernate.StatelessSession; //导入方法依赖的package包/类
private void executeRemove(StatelessSession session, BulkItem bulkItem) {
Object entry = bulkItem.getItem();
if (logger.isTraceEnabled()) {
logger.trace("[Optimistic REMOVE] Deleting Entry [" + entry + "]");
}
session.delete(entry);
}
示例4: testInitId
import org.hibernate.StatelessSession; //导入方法依赖的package包/类
public void testInitId() {
StatelessSession ss = getSessions().openStatelessSession();
Transaction tx = ss.beginTransaction();
Paper paper = new Paper();
paper.setColor( "White" );
ss.insert(paper);
assertNotNull( paper.getId() );
tx.commit();
tx = ss.beginTransaction();
ss.delete( ss.get( Paper.class, paper.getId() ) );
tx.commit();
ss.close();
}
示例5: testCreateUpdateReadDelete
import org.hibernate.StatelessSession; //导入方法依赖的package包/类
public void testCreateUpdateReadDelete() {
StatelessSession ss = getSessions().openStatelessSession();
Transaction tx = ss.beginTransaction();
Document doc = new Document("blah blah blah", "Blahs");
ss.insert(doc);
assertNotNull( doc.getName() );
Date initVersion = doc.getLastModified();
assertNotNull( initVersion );
tx.commit();
tx = ss.beginTransaction();
doc.setText("blah blah blah .... blah");
ss.update(doc);
assertNotNull( doc.getLastModified() );
assertNotSame( doc.getLastModified(), initVersion );
tx.commit();
tx = ss.beginTransaction();
doc.setText("blah blah blah .... blah blay");
ss.update(doc);
tx.commit();
Document doc2 = (Document) ss.get(Document.class.getName(), "Blahs");
assertEquals("Blahs", doc2.getName());
assertEquals(doc.getText(), doc2.getText());
doc2 = (Document) ss.createQuery("from Document where text is not null").uniqueResult();
assertEquals("Blahs", doc2.getName());
assertEquals(doc.getText(), doc2.getText());
ScrollableResults sr = ss.createQuery("from Document where text is not null")
.scroll(ScrollMode.FORWARD_ONLY);
sr.next();
doc2 = (Document) sr.get(0);
sr.close();
assertEquals("Blahs", doc2.getName());
assertEquals(doc.getText(), doc2.getText());
doc2 = (Document) ss.createSQLQuery("select * from Document")
.addEntity(Document.class)
.uniqueResult();
assertEquals("Blahs", doc2.getName());
assertEquals(doc.getText(), doc2.getText());
doc2 = (Document) ss.createCriteria(Document.class).uniqueResult();
assertEquals("Blahs", doc2.getName());
assertEquals(doc.getText(), doc2.getText());
sr = ss.createCriteria(Document.class).scroll(ScrollMode.FORWARD_ONLY);
sr.next();
doc2 = (Document) sr.get(0);
sr.close();
assertEquals("Blahs", doc2.getName());
assertEquals(doc.getText(), doc2.getText());
tx = ss.beginTransaction();
ss.delete(doc);
tx.commit();
ss.close();
}