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


Java Session类代码示例

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


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

示例1: convertDataValueToObjectValue

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public Object convertDataValueToObjectValue(Object dataValue, Session session) {
    try {
        if (session.getPlatform() instanceof PostgreSQLPlatform) {
            return dataValue;
        } else if (session.getPlatform() instanceof OraclePlatform
                || session.getPlatform() instanceof MySQLPlatform) {
            if (dataValue instanceof String) {
                StringBuilder sb = new StringBuilder((String) dataValue);
                sb.insert(8, '-');
                sb.insert(13, '-');
                sb.insert(18, '-');
                sb.insert(23, '-');
                return UuidProvider.fromString(sb.toString());
            } else {
                return dataValue;
            }
        } else {
            return dataValue instanceof String ? UuidProvider.fromString((String) dataValue) : dataValue;
        }
    } catch (Exception e) {
        throw new RuntimeException("Error creating UUID from database value '" + dataValue + "'", e);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:UuidConverter.java

示例2: customize

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void customize(Session session) throws Exception {
	
	logger.info("---> CUSTOMIZE <---");
	
	/*
	session.getEventManager().addListener(new SessionEventAdapter() {
           @Override
           public void postLogin(SessionEvent event) {
               String fileName = ""; //(String) event.getSession().getProperty("import.sql.file");
               UnitOfWork unitOfWork = event.getSession().acquireUnitOfWork();
               importSql(unitOfWork, fileName);
               unitOfWork.commit();
               
               logger.info("---> POST LOGIN <---");
           }    
       });
       */

}
 
开发者ID:SAP,项目名称:sap_mobile_platform_espm_olingo_services,代码行数:21,代码来源:ExtraDDL.java

示例3: customize

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void customize(Session session) throws Exception {
    for (ClassDescriptor descriptor : session.getDescriptors().values()) {
        if (!descriptor.getTables().isEmpty() && descriptor.getAlias().equalsIgnoreCase(descriptor.getTableName())) {
            String tableName = addUnderscores(descriptor.getAlias()).toUpperCase();
            System.out.println(descriptor.getAlias() + ":" + tableName);
            descriptor.setTableName(tableName);

            DatabaseTable databaseTable = descriptor.getTables().get(0);
            for (IndexDefinition indexDef : databaseTable.getIndexes()) {
                indexDef.setTargetTable(tableName);
            }
        }

        for (DatabaseMapping mapping : descriptor.getMappings()) {
            if (mapping.getField() != null
                    && !mapping.getAttributeName().isEmpty()
                    && mapping.getField().getName().equalsIgnoreCase(mapping.getAttributeName())) {
                mapping.getField().setName(
                        addUnderscores(mapping.getAttributeName()).toUpperCase()
                );
            }
        }
    }
}
 
开发者ID:kawasima,项目名称:occupy-pub,代码行数:26,代码来源:SnakeCaseNameMapping.java

示例4: customize

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void customize(Session session) throws Exception {
    String sessionName = session.getName();

    // double-checked locking on ConcurrentMap
    List<Sequence> sequences = sequenceMap.get(sessionName);
    if (sequences == null) {
        sequences = sequenceMap.putIfAbsent(sessionName, loadSequences(session));
        if (sequences == null) {
            sequences = sequenceMap.get(sessionName);
        }
    }

    loadQueryCustomizers(session);

    DatabaseLogin login = session.getLogin();
    for (Sequence sequence : sequences) {
        login.addSequence(sequence);
    }

    handleDescriptorModifications(session);

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:KradEclipseLinkCustomizer.java

示例5: loadQueryCustomizers

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
/**
 * Load Query Customizer based on annotations on fields and call customizer to modify descriptor.
 *
 * @param session the EclipseLink session.
 */
protected void loadQueryCustomizers(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();
    for (Class<?> entityClass : descriptors.keySet()) {
        for (Field field : entityClass.getDeclaredFields()) {
            String queryCustEntry = entityClass.getName() + "_" + field.getName();
            buildQueryCustomizers(entityClass,field,queryCustEntry);

            List<FilterGenerator> queryCustomizers = queryCustomizerMap.get(queryCustEntry);
            if (queryCustomizers != null && !queryCustomizers.isEmpty()) {
                Filter.customizeField(queryCustomizers, descriptors.get(entityClass), field.getName());
            }
        }
    }

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:21,代码来源:KradEclipseLinkCustomizer.java

示例6: handleDescriptorModifications

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
/**
 * Determines if the class descriptors have been modified for the given session name.
 *
 * @param session the current session.
 */
protected void handleDescriptorModifications(Session session) {
    String sessionName = session.getName();

    // double-checked locking on ConcurrentMap
    Boolean descModified = modDescMap.get(sessionName);
    if (descModified == null) {
        descModified = modDescMap.putIfAbsent(sessionName, Boolean.FALSE);
        if (descModified == null) {
            descModified = modDescMap.get(sessionName);
        }
    }

    if (Boolean.FALSE.equals(descModified)) {
        modDescMap.put(sessionName, Boolean.TRUE);
        handleDisableVersioning(session);
        handleRemoveMapping(session);
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:KradEclipseLinkCustomizer.java

示例7: handleDisableVersioning

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
/**
 * Checks class descriptors for {@link @DisableVersioning} annotations at the class level and removes the version
 * database mapping for optimistic locking.
 *
 * @param session the current session.
 */
protected void handleDisableVersioning(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();

    if (descriptors == null || descriptors.isEmpty()) {
        return;
    }

    for (ClassDescriptor classDescriptor : descriptors.values()) {
        if (classDescriptor != null && AnnotationUtils.findAnnotation(classDescriptor.getJavaClass(),
                DisableVersioning.class) != null) {
            OptimisticLockingPolicy olPolicy = classDescriptor.getOptimisticLockingPolicy();
            if (olPolicy != null) {
                classDescriptor.setOptimisticLockingPolicy(null);
            }
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:KradEclipseLinkCustomizer.java

示例8: customize

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void customize(final Session session) throws SQLException {
    for (ClassDescriptor descriptor : session.getDescriptors().values()) {
        if (!descriptor.getTables().isEmpty()) {
            // Take table name from @Table if exists
            String tableName = null;
            if (descriptor.getAlias().equalsIgnoreCase(descriptor.getTableName())) {
                tableName = unqualify(descriptor.getJavaClassName());
            } else {
                tableName = descriptor.getTableName();
            }
            tableName = camelCaseToUnderscore(tableName);
            descriptor.setTableName(tableName);

            for (IndexDefinition index : descriptor.getTables().get(0).getIndexes()) {
                index.setTargetTable(tableName);
            }
            Vector<DatabaseMapping> mappings = descriptor.getMappings();
            camelCaseToUnderscore(mappings);
        } else if (descriptor.isAggregateDescriptor() || descriptor.isChildDescriptor()) {
            camelCaseToUnderscore(descriptor.getMappings());
        }
    }
}
 
开发者ID:antoniomaria,项目名称:karaf4-eclipselink-jpa,代码行数:25,代码来源:CamelNamingStrategy.java

示例9: customize

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void customize(final Session session) throws SQLException {
    for (ClassDescriptor descriptor : session.getDescriptors().values()) {
        if (!descriptor.getTables().isEmpty()) {
            // Take table name from @Table if exists
            String tableName = null;
            if (descriptor.getAlias().equalsIgnoreCase(descriptor.getTableName())) {
                tableName = unqualify(descriptor.getJavaClassName());
            } else {
                tableName = descriptor.getTableName();
            }
            tableName = camelCaseToUnderscore(tableName);
            descriptor.setTableName(tableName);
            for (IndexDefinition index : descriptor.getTables().get(0).getIndexes()) {
                index.setTargetTable(tableName);
            }
            Vector<DatabaseMapping> mappings = descriptor.getMappings();
            camelCaseToUnderscore(mappings);
        } else if (descriptor.isAggregateDescriptor() || descriptor.isChildDescriptor()) {
            camelCaseToUnderscore(descriptor.getMappings());
        }
    }
}
 
开发者ID:StefanSchubert,项目名称:sabi,代码行数:24,代码来源:JPACamelCaseNamingStrategy.java

示例10: clean

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
/**
 * This method deletes data from JPA tables created. This method reads comma
 * separated SQL delete statements from DataDeleteSQLs properties files and
 * executes them in order.
 */
public void clean() {
  // Delete using SQLs
  String[] deleteStatements = getSQLDeleteStatements();
  if (deleteStatements.length > 0) { // If configuration is proper with at least one delete Statements
    Session session = ((EntityManagerImpl) entityManager).getActiveSession();
    entityManager.getTransaction().begin();
    for (String deleteStatement : deleteStatements) {
      System.out.println("Cleaning - " + deleteStatement);
      SQLCall sqlCall = new SQLCall(deleteStatement);

      DataModifyQuery query = new DataModifyQuery();
      query.setCall(sqlCall);
      session.executeQuery(query);
    }
    entityManager.getTransaction().commit();
  } else {
    System.err.println("Delete configuration file doesn't have any delete statements.");
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:DataGenerator.java

示例11: fireSQL

import org.eclipse.persistence.sessions.Session; //导入依赖的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

示例12: postInsert

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void postInsert(DescriptorEvent event) {
	Object entity = event.getObject();
	Class<?> entityClass = INSTANCE_INITIALIZER.getClass( entity );
	Object id = EclipseLinkUpdateSource.this.getId( entityClass, entity );
	if ( id == null ) {
		throw new SearchException( "id was null for " + entity );
	}
	if ( EclipseLinkUpdateSource.this.indexRelevantEntities.contains( entityClass ) ) {
		LOGGER.fine( "Insert Event for " + entity );
		Session session = event.getSession();
		if ( session.isUnitOfWork() ) {
			session = ((UnitOfWork) session).getParent();
		}
		EclipseLinkUpdateSource.this.enlistWork( session, entityClass, entity, id, EventType.INSERT );
	}
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:18,代码来源:EclipseLinkUpdateSource.java

示例13: postUpdate

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void postUpdate(DescriptorEvent event) {
	Object entity = event.getObject();
	Class<?> entityClass = INSTANCE_INITIALIZER.getClass( entity );
	Object id = EclipseLinkUpdateSource.this.getId( entityClass, entity );
	if ( id == null ) {
		throw new SearchException( "id was null for " + entity );
	}
	if ( EclipseLinkUpdateSource.this.indexRelevantEntities.contains( entityClass ) ) {
		LOGGER.fine( "Update Event for " + entity );
		Session session = event.getSession();
		if ( session.isUnitOfWork() ) {
			session = ((UnitOfWork) session).getParent();
		}
		EclipseLinkUpdateSource.this.enlistWork( session, entityClass, entity, id, EventType.UPDATE );
	}
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:18,代码来源:EclipseLinkUpdateSource.java

示例14: postCommitTransaction

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public void postCommitTransaction(SessionEvent event) {
	Session session = event.getSession();
	Transaction tx = EclipseLinkUpdateSource.this.transactionsPerSession.get( session );
	if ( tx != null && tx.isTransactionInProgress() ) {
		tx.commit();
		List<UpdateConsumer.UpdateEventInfo> updateEventInfos = EclipseLinkUpdateSource.this.updateEventInfos
				.remove(
						tx
				);
		EclipseLinkUpdateSource.this.notify( updateEventInfos );
		EclipseLinkUpdateSource.this.transactionsPerSession.remove( session );
	}
	else {
		LOGGER.warning(
				"received commit event from EclipseLink and transaction should have been in progress, but wasn't"
		);
	}
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:20,代码来源:EclipseLinkUpdateSource.java

示例15: convertDataValueToObjectValue

import org.eclipse.persistence.sessions.Session; //导入依赖的package包/类
@Override
public Object convertDataValueToObjectValue(final Object data, final Session session) {
    if (data == null) {
        return getConvertableEnum();
    }

    final Object convertableEnum = getConvertableEnum().getFromValue(data);

    if (convertableEnum == null) {
        throw new IllegalArgumentException(
                "Data not with a value suitable got [" + data.getClass() + " : " + data
                        + "] expected a valid value of ["
                        + getConvertableEnum().getClass() + "]"
        );
    } else {
        return convertableEnum;
    }
}
 
开发者ID:mhmxs,项目名称:SpringClips,代码行数:19,代码来源:AbstractEnumConverter.java


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