javax.persistence.EntityListeners Java Examples
The following examples show how to use
javax.persistence.EntityListeners.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAOverriddenAnnotationReader.java From lams with GNU General Public License v2.0 | 5 votes |
private EntityListeners getEntityListeners(Element tree, XMLContext.Default defaults) { Element element = tree != null ? tree.element( "entity-listeners" ) : null; if ( element != null ) { List<Class> entityListenerClasses = new ArrayList<>(); for ( Element subelement : (List<Element>) element.elements( "entity-listener" ) ) { String className = subelement.attributeValue( "class" ); try { entityListenerClasses.add( classLoaderAccess.classForName( XMLContext.buildSafeClassName( className, defaults ) ) ); } catch ( ClassLoadingException e ) { throw new AnnotationException( "Unable to find " + element.getPath() + ".class: " + className, e ); } } AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class ); ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) ); return AnnotationFactory.create( ad ); } else if ( defaults.canUseJavaAnnotations() ) { return getPhysicalAnnotation( EntityListeners.class ); } else { return null; } }
Example #2
Source File: JPAEdmEntityType.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public void build() throws ODataJPAModelException, ODataJPARuntimeException { Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities(); if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true) { return; } else if (consistentEntityTypes == null) { consistentEntityTypes = new EntityTypeList<EntityType>(); } for (javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) { currentEdmEntityType = new EntityType(); currentJPAEntityType = jpaEntityType; // Check for need to Exclude if (isExcluded(JPAEdmEntityType.this)) { continue; } JPAEdmNameBuilder.build(JPAEdmEntityType.this); JPAEdmMapping jpaEdmMapping = (JPAEdmMapping) currentEdmEntityType.getMapping(); EntityListeners entityListners = currentJPAEntityType.getJavaType().getAnnotation(EntityListeners.class); if (entityListners != null) { for (Class<EntityListeners> entityListner : entityListners.value()) { if (ODataJPATombstoneEntityListener.class.isAssignableFrom(entityListner)) { jpaEdmMapping .setODataJPATombstoneEntityListener((Class<? extends ODataJPATombstoneEntityListener>) (Object) entityListner); break; } } } JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView); propertyView.getBuilder().build(); currentEdmEntityType.setProperties(propertyView.getEdmPropertyList()); if (propertyView.getJPAEdmNavigationPropertyView() != null) { JPAEdmNavigationPropertyView navPropView = propertyView.getJPAEdmNavigationPropertyView(); if (navPropView.getConsistentEdmNavigationProperties() != null && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) { currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties()); } } JPAEdmKeyView keyView = propertyView.getJPAEdmKeyView(); currentEdmEntityType.setKey(keyView.getEdmKey()); consistentEntityTypes.add(currentEdmEntityType); consistentEntityTypeMap.put(currentJPAEntityType.getName(), currentEdmEntityType); } }