本文整理汇总了Java中org.eclipse.persistence.sessions.Session.getDescriptors方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getDescriptors方法的具体用法?Java Session.getDescriptors怎么用?Java Session.getDescriptors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.persistence.sessions.Session
的用法示例。
在下文中一共展示了Session.getDescriptors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
}
}
示例2: 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);
}
}
}
}
示例3: customize
import org.eclipse.persistence.sessions.Session; //导入方法依赖的package包/类
@Override
public void customize(Session session) throws Exception
{
handler = new EclipseLinkToSpringContextBridge();
@SuppressWarnings("rawtypes")
final Map<Class, ClassDescriptor> descriptors = session.getDescriptors();
for (ClassDescriptor descriptor : descriptors.values())
{
descriptor.getDescriptorEventManager().addEntityListenerEventListener(handler);
}
}
示例4: handleRemoveMapping
import org.eclipse.persistence.sessions.Session; //导入方法依赖的package包/类
/**
* Checks class descriptors for {@link @RemoveMapping} and {@link RemoveMappings} annotations at the class level
* and removes any specified mappings from the ClassDescriptor.
*
* @param session the current session.
*/
protected void handleRemoveMapping(Session session) {
Map<Class, ClassDescriptor> descriptors = session.getDescriptors();
if (descriptors == null || descriptors.isEmpty()) {
return;
}
for (ClassDescriptor classDescriptor : descriptors.values()) {
List<DatabaseMapping> mappingsToRemove = new ArrayList<DatabaseMapping>();
List<RemoveMapping> removeMappings = scanForRemoveMappings(classDescriptor);
for (RemoveMapping removeMapping : removeMappings) {
if (StringUtils.isBlank(removeMapping.name())) {
throw DescriptorException.attributeNameNotSpecified();
}
DatabaseMapping databaseMapping = classDescriptor.getMappingForAttributeName(removeMapping.name());
if (databaseMapping == null) {
throw DescriptorException.mappingForAttributeIsMissing(removeMapping.name(), classDescriptor);
}
mappingsToRemove.add(databaseMapping);
}
for (DatabaseMapping mappingToRemove : mappingsToRemove) {
classDescriptor.removeMappingForAttributeName(mappingToRemove.getAttributeName());
}
}
}
示例5: customize
import org.eclipse.persistence.sessions.Session; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void customize(Session session) throws Exception {
Map<Class, ClassDescriptor> descriptors = session.getDescriptors();
// iterate all descriptors
for (ClassDescriptor classDescriptor : descriptors.values()) {
// iterate the mappings of each descriptor
for (DatabaseMapping databaseMapping : classDescriptor.getMappings()) {
// process embedded properties
if (databaseMapping.isAggregateObjectMapping()) {
AggregateObjectMapping m = (AggregateObjectMapping) databaseMapping;
Map<String, DatabaseField> fieldMapping = m.getAggregateToSourceFields();
// iterate the mappings of the embeddable class
for (DatabaseMapping refMapping : descriptors.get(m.getReferenceClass()).getMappings()) {
if (refMapping.isDirectToFieldMapping()) {
DirectToFieldMapping refDirectMapping = (DirectToFieldMapping) refMapping;
String refFieldName = refDirectMapping.getField().getName();
if (!fieldMapping.containsKey(refFieldName)) {
DatabaseField mappedField = refDirectMapping.getField().clone();
mappedField.setName(m.getAttributeName() + "_" + mappedField.getName());
fieldMapping.put(refFieldName, mappedField);
}
}
}
}
}
}
}
示例6: preLogin
import org.eclipse.persistence.sessions.Session; //导入方法依赖的package包/类
@Override
public void preLogin( final SessionEvent event )
{
final Session session = event.getSession();
boolean isSqlServer = false;
boolean isPostgreSQL = false;
final String geomDriver = (String) session.getProperty( "geolatte.geom.driver" );
if ( null != geomDriver )
{
isSqlServer = geomDriver.equals( "sqlserver" );
isPostgreSQL = geomDriver.equals( "postgres" );
}
else
{
final String driver = (String) session.getProperty( "javax.persistence.jdbc.driver" );
if ( null != driver )
{
isSqlServer = driver.contains( ".jtds." );
isPostgreSQL = driver.contains( "org.postgresql." );
}
}
if ( !isSqlServer && !isPostgreSQL )
{
final String message =
"Unable to determine database type. Explicitly set jpa " +
"property 'geolatte.geom.driver' to 'sqlserver' or 'postgres'" ;
throw new IllegalStateException( message );
}
final Map<Class, ClassDescriptor> descriptorMap = session.getDescriptors();
// Walk through all descriptors...
for ( final Map.Entry<Class, ClassDescriptor> entry : descriptorMap.entrySet() )
{
final ClassDescriptor desc = entry.getValue();
final Vector<DatabaseMapping> mappings = desc.getMappings();
// walk through all mappings for some class...
for ( final DatabaseMapping mapping : mappings )
{
if ( mapping instanceof DirectToFieldMapping )
{
final DirectToFieldMapping dfm = (DirectToFieldMapping) mapping;
if ( isCandidateConverter( dfm ) )
{
final Class type = entry.getKey();
final String attributeName = dfm.getAttributeName();
final Field field = getField( type, attributeName );
final Class<?> fieldType = field.getType();
if ( Point.class == fieldType ||
Polygon.class == fieldType ||
LinearRing.class == fieldType ||
LineString.class == fieldType ||
MultiPoint.class == fieldType ||
MultiPolygon.class == fieldType ||
MultiLineString.class == fieldType ||
Geometry.class == fieldType ||
GeometryCollection.class == fieldType )
{
final Converter converter = isSqlServer ? new SqlServerConverter() : new PostgisConverter();
converter.initialize( mapping, session );
dfm.setConverter( converter );
}
}
}
}
}
}