当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseRecord类代码示例

本文整理汇总了Java中org.eclipse.persistence.sessions.DatabaseRecord的典型用法代码示例。如果您正苦于以下问题:Java DatabaseRecord类的具体用法?Java DatabaseRecord怎么用?Java DatabaseRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DatabaseRecord类属于org.eclipse.persistence.sessions包,在下文中一共展示了DatabaseRecord类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fireSQL

import org.eclipse.persistence.sessions.DatabaseRecord; //导入依赖的package包/类
private void fireSQL(TypedQuery<T> q, EntityManager em){
    String sql;

    // warning!!! highly unportable detection method
    if (em.getProperties().containsKey("org.hibernate.flushMode")){ // hibernate
        sql = q.unwrap(org.hibernate.Query.class).getQueryString();
    }
    else{ // eclipselink
        Session session = em.unwrap(JpaEntityManager.class).getActiveSession();
        DatabaseQuery databaseQuery = ((EJBQueryImpl)q).getDatabaseQuery();
        databaseQuery.prepareCall(session, new DatabaseRecord());
        sql = databaseQuery.getSQLString();
    }

    eventBus.fire(sql);
}
 
开发者ID:sasa7812,项目名称:jfbdemo,代码行数:17,代码来源:LazyLoadServiceImpl.java

示例2: assertSQL

import org.eclipse.persistence.sessions.DatabaseRecord; //导入依赖的package包/类
protected void assertSQL(TypedQuery<Employee> tq, String expected){
    Session session = em.unwrap(JpaEntityManager.class).getActiveSession();
    DatabaseQuery databaseQuery = ((EJBQueryImpl)tq).getDatabaseQuery();
    databaseQuery.prepareCall(session, new DatabaseRecord());
    String actual = databaseQuery.getSQLString();
    //String actual = tq.unwrap(EJBQueryImpl.class).getDatabaseQuery().getSQLString();
    assertEquals(expected, actual);
}
 
开发者ID:sasa7812,项目名称:jfbdemo,代码行数:9,代码来源:FilterCriteriaBuilderEclipseLinkTest.java

示例3: queryIndexOf

import org.eclipse.persistence.sessions.DatabaseRecord; //导入依赖的package包/类
private Integer queryIndexOf(final JpaEntityItem<TEntityType> item) {
        final EntityManager em = lookup(EntityManager.class);
        final CriteriaBuilder cb = em.getCriteriaBuilder();
        final CriteriaQuery query = cb.createQuery();
        final Root<TEntityType> root = query.from(entityClass);

        // Добавляем фильтр контейнера
        final List<Predicate> predicates = createContainerFilterPredicates(cb, query, root);
        if (!predicates.isEmpty()) {
            query.where(CollectionUtil.toArray(Predicate.class, predicates));
        }

        // Добавляем сортировку
        final List<JpaSortBy> sortByList = sortBySupplier.get();
        if (!sortByList.isEmpty()) {
            final List<Order> orders = newArrayListWithCapacity(sortByList.size());
            for (final JpaSortBy sortBy : sortByList)
                orders.add(translateSortBy(sortBy, cb, root));
            query.orderBy(orders);
        }

        final Path<String> idPath = root.get(IdentifiedObject_.id);
        query.select(idPath).distinct(true);

        final TypedQuery<Long> tq = em.createQuery(query);
        final DatabaseQuery databaseQuery = tq.unwrap(JpaQuery.class).getDatabaseQuery();
        final DatabaseRecord translationRow = new DatabaseRecord();
        final JpaEntityManager jpaEm = em.unwrap(JpaEntityManager.class);
        databaseQuery.prepareCall(jpaEm.getSession(), translationRow);
        final String querySql = databaseQuery.getTranslatedSQLString(jpaEm.getSession(), translationRow);
        final String itemId = item.getBean().getId();
        final Query nativeQuery = em.createNativeQuery(
                MessageFormat.format(
                        "SELECT q.rownum AS indx " +
                                "FROM (SELECT s.{2} AS id, (@rownum:[email protected] + 1) - 1 AS rownum " +
                                "           FROM (SELECT @rownum:=0) i, ({0}) s) q " +
                                "WHERE q.id = ''{1}''", querySql, itemId, IdentifiedObject_.id.getName()));
//            nativeQuery.unwrap(JpaQuery.class).getDatabaseQuery().setTranslationRow(translationRow);
        final Object result;
        try {
            result = nativeQuery.getSingleResult();
        } catch (final NoResultException e) {
            return -1;
        }

        return result != null /*&& result instanceof Number*/ ? ((Number) result).intValue() : -1;
    }
 
开发者ID:ExtaSoft,项目名称:extacrm,代码行数:48,代码来源:JpaLazyItemList.java


注:本文中的org.eclipse.persistence.sessions.DatabaseRecord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。