org.hibernate.query.Query.executeUpdate()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(299)

本文整理了Java中org.hibernate.query.Query.executeUpdate方法的一些代码示例,展示了Query.executeUpdate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.executeUpdate方法的具体详情如下:
包路径:org.hibernate.query.Query
类名称:Query
方法名:executeUpdate

Query.executeUpdate介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

private void cleanDb(Session s) {
  s.createQuery( "delete Locality" ).executeUpdate();
  s.createQuery( "delete Country" ).executeUpdate();
  s.createQuery( "delete Continent" ).executeUpdate();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void cleanupTestData() throws Exception {
  doInHibernate( this::sessionFactory, sess -> {
    sess.createQuery( "delete from Book" ).executeUpdate();
    sess.createQuery( "delete from Library" ).executeUpdate();
  } );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testDeleteSyntaxWithCompositeId() {
  Session s = openSession();
  Transaction t = s.beginTransaction();
  s.createQuery( "delete EntityWithCrazyCompositeKey where id.id = 1 and id.otherId = 2" ).executeUpdate();
  s.createQuery( "delete from EntityWithCrazyCompositeKey where id.id = 1 and id.otherId = 2" ).executeUpdate();
  s.createQuery( "delete from EntityWithCrazyCompositeKey e where e.id.id = 1 and e.id.otherId = 2" ).executeUpdate();
  t.commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

private void cleanupData() {
  Session session = openSession();
  session.beginTransaction();
  session.createQuery( "delete Tranche" ).executeUpdate();
  session.createQuery( "delete Tranchenmodell" ).executeUpdate();
  session.createQuery( "delete Preisregelung" ).executeUpdate();
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

private void cleanupData() {
  Session session = openSession();
  session.beginTransaction();
  session.createQuery( "delete EmployeeInfo" ).executeUpdate();
  session.createQuery( "delete Employee" ).executeUpdate();
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@After
public void tearDown() {
  doInHibernate( this::sessionFactory, session -> {
    session.createQuery( "DELETE FROM User" ).executeUpdate();
    session.createQuery( "DELETE FROM Role" ).executeUpdate();
  } );
}

代码示例来源:origin: hibernate/hibernate-orm

private void cleanupData() {
  Session session = openSession();
  session.beginTransaction();
  session.createQuery( "delete Employee" ).executeUpdate();
  session.createQuery( "delete EmployeeInfo" ).executeUpdate();
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

private void cleanUpData() {
  Session session = openSession();
  session.beginTransaction();
  session.createQuery( "delete Shipment" ).executeUpdate();
  session.createQuery( "delete Item" ).executeUpdate();
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void cleanupTest() throws Exception {
  Session s = openSession();
  s.beginTransaction();
  s.createQuery( "delete from org.hibernate.test.cache.User" ).executeUpdate();
  s.createQuery( "delete from org.hibernate.test.cache.Company" ).executeUpdate();
  s.getTransaction().commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void cleanupTest() throws Exception {
  Session s = openSession();
  s.beginTransaction();
  s.createQuery( "delete from org.hibernate.test.cache.User" ).executeUpdate();
  s.createQuery( "delete from org.hibernate.test.cache.Company" ).executeUpdate();
  s.getTransaction().commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

private void deleteData() throws Exception {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    s.createQuery( "delete from Widget" ).executeUpdate();
    t.commit();
    s.close();
  }
}

代码示例来源:origin: hibernate/hibernate-orm

private void cleanupData() {
  Session session = openSession();
  session.beginTransaction();
  session.createQuery( "delete EmployeeInfo" ).executeUpdate();
  session.createQuery( "delete Employee" ).executeUpdate();
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

private void cleanupData() {
  Session session = openSession();
  session.beginTransaction();
  session.createQuery( "delete EmployeeInfo" ).executeUpdate();
  session.createQuery( "delete Employee" ).executeUpdate();
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@After
public void cleanupData() {
  super.cleanupCache();
  Session s = sessionFactory().openSession();
  s.beginTransaction();
  s.createQuery( "delete NaturalIdOnManyToOne" ).executeUpdate();
  s.createQuery( "delete Citizen" ).executeUpdate();
  s.createQuery( "delete State" ).executeUpdate();
  s.getTransaction().commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void cleanupTest() throws Exception {
  openSession();
  session.beginTransaction();
  
  session.createQuery("delete from Human").executeUpdate();
  
  session.getTransaction().commit();
  session.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@After
public void tearDown() {
  doInHibernate( this::sessionFactory, session -> {
            session.createQuery( "delete from Game" ).executeUpdate();
          }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testDeleteOnMappedJoin() {
  TestData data = new TestData();
  data.prepare();
  Session s = openSession();
  Transaction t = s.beginTransaction();
  int count = s.createQuery( "delete Joiner where joinedName = :joinedName" ).setString( "joinedName", "joined-name" ).executeUpdate();
  assertEquals( "Incorrect deletion count on joined subclass", 1, count );
  t.commit();
  s.close();
  data.cleanup();
}

代码示例来源:origin: hibernate/hibernate-orm

@After
public void cleanup() {
  Session s = openSession();
  s.getTransaction().begin();
  s.createQuery( "delete from ByteArrayIdTest$DemoEntity" ).executeUpdate();
  s.getTransaction().commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testDeleteFromPerson() {
  doInHibernate( this::sessionFactory, session -> {
    //tag::batch-bulk-hql-temp-table-delete-query-example[]
    int updateCount = session.createQuery(
      "delete from Person where employed = :employed" )
    .setParameter( "employed", false )
    .executeUpdate();
    //end::batch-bulk-hql-temp-table-delete-query-example[]
    assertEquals( entityCount(), updateCount );
  });
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testDeleteFromEngineer() {
  doInHibernate( this::sessionFactory, session -> {
    int updateCount = session.createQuery( "delete from Engineer where fellow = :fellow" )
        .setParameter( "fellow", true )
        .executeUpdate();
    assertEquals( entityCount() / 2, updateCount );
  });
}

相关文章