Examples of PersistenceContext


Examples of javax.persistence.PersistenceContext

      super(finder);
   }

   public void process(PersistenceContextReferencesMetaData refs, E element)
   {
      PersistenceContext annotation = finder.getAnnotation(element, PersistenceContext.class);
      if(annotation == null)
         return;

      process(refs, element, annotation);
   }
View Full Code Here

Examples of net.fortytwo.twitlogic.persistence.PersistenceContext

        try {
            TweetStoreConnection c = store.createConnection();

            try {
                PersistenceContext pc
                        = new PersistenceContext(c);

                PlacePersistenceHelper ph = new PlacePersistenceHelper(pc, client, false);
                for (String id : ids) {
                    Place p = new Place(id);
                    Feature f = pc.persist(p);
                    ph.submit(p, f);
                    c.commit();
                }
            } finally {
                c.rollback();
View Full Code Here

Examples of org.apache.stratos.manager.subscription.PersistenceContext

        subscriptionData.setCommitsEnabled(cartridgeInfoBean.isCommitsEnabled());
        subscriptionData.setServiceGroup(cartridgeInfoBean.getServiceGroup());
       
        if (cartridgeInfoBean.isPersistanceRequired()) {
            // Add persistence related properties to PersistenceContext
            PersistenceContext persistenceContext = new PersistenceContext();
            persistenceContext.setPersistanceRequiredProperty(IS_VOLUME_REQUIRED, String.valueOf(cartridgeInfoBean.isPersistanceRequired()));
            persistenceContext.setSizeProperty(VOLUME_SIZE, cartridgeInfoBean.getSize());
            persistenceContext.setDeleteOnTerminationProperty(SHOULD_DELETE_VOLUME, String.valueOf(cartridgeInfoBean.isRemoveOnTermination()));
            subscriptionData.setPersistanceCtxt(persistenceContext);
        }

        //subscribe
        return cartridgeSubsciptionManager.subscribeToCartridgeWithProperties(subscriptionData);
View Full Code Here

Examples of org.drools.persistence.PersistenceContext

   
    public void internalExecuteWorkItem(WorkItem workItem) {
        Environment env = this.kruntime.getEnvironment();
        WorkItemInfo workItemInfo = new WorkItemInfo(workItem, env);
       
        PersistenceContext context = ((PersistenceContextManager) env.get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )).getCommandScopedPersistenceContext();
        workItemInfo = context.persist( workItemInfo );
       
        ((WorkItemImpl) workItem).setId(workItemInfo.getId());
        workItemInfo.transform();
       
        if (this.workItems == null) {
View Full Code Here

Examples of org.eclipse.persistence.jpa.rs.PersistenceContext

*
*/
public abstract class AbstractQueryResource extends AbstractResource {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected Response namedQueryUpdateInternal(String version, String persistenceUnit, String name, HttpHeaders hh, UriInfo ui) {
        PersistenceContext app = getPersistenceContext(persistenceUnit, ui.getBaseUri(), version, null);
        if (app == null) {
            JPARSLogger.fine("jpars_could_not_find_persistence_context", new Object[] { persistenceUnit });
            return Response.status(Status.NOT_FOUND).type(StreamingOutputMarshaller.getResponseMediaType(hh)).build();
        }
        int result = app.queryExecuteUpdate(getMatrixParameters(ui, persistenceUnit), name, getMatrixParameters(ui, name), getQueryParameters(ui));
        JAXBElement jaxbElement = new JAXBElement(new QName(StreamingOutputMarshaller.NO_ROUTE_JAXB_ELEMENT_LABEL), new Integer(result).getClass(), result);
        return Response.ok(new StreamingOutputMarshaller(app, jaxbElement, hh.getAcceptableMediaTypes())).build();
    }
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

  private List doQueryAndInitializeNonLazyCollections(final SessionImplementor session,
                            final QueryParameters queryParameters,
                            final boolean returnProxies)
    throws HibernateException, SQLException {

    final PersistenceContext persistenceContext = session.getPersistenceContext();
    persistenceContext.beforeLoad();
    List result;
    try {
      result = doQuery( session, queryParameters, returnProxies );
    }
    finally {
      persistenceContext.afterLoad();
    }
    persistenceContext.initializeNonLazyCollections();
    return result;
  }
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

        int owner = owners[i];
        if ( owner > -1 ) {
          EntityKey ownerKey = keys[owner];
          if ( keys[i] == null && ownerKey != null ) {
           
            final PersistenceContext persistenceContext = session.getPersistenceContext();
           
            /*final boolean isPrimaryKey;
            final boolean isSpecialOneToOne;
            if ( ownerAssociationTypes == null || ownerAssociationTypes[i] == null ) {
              isPrimaryKey = true;
              isSpecialOneToOne = false;
            }
            else {
              isPrimaryKey = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName()==null;
              isSpecialOneToOne = ownerAssociationTypes[i].getLHSPropertyName()!=null;
            }*/
           
            //TODO: can we *always* use the "null property" approach for everything?
            /*if ( isPrimaryKey && !isSpecialOneToOne ) {
              persistenceContext.addNonExistantEntityKey(
                  new EntityKey( ownerKey.getIdentifier(), persisters[i], session.getEntityMode() )
              );
            }
            else if ( isSpecialOneToOne ) {*/
            boolean isOneToOneAssociation = ownerAssociationTypes!=null &&
                ownerAssociationTypes[i]!=null &&
                ownerAssociationTypes[i].isOneToOne();
            if ( isOneToOneAssociation ) {
              persistenceContext.addNullProperty( ownerKey,
                  ownerAssociationTypes[i].getPropertyName() );
            }
            /*}
            else {
              persistenceContext.addNonExistantEntityUniqueKey( new EntityUniqueKey(
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

          final CollectionAliases descriptor,
          final ResultSet rs,
          final SessionImplementor session)
  throws HibernateException, SQLException {

    final PersistenceContext persistenceContext = session.getPersistenceContext();

    final Serializable collectionRowKey = (Serializable) persister.readKey(
        rs,
        descriptor.getSuffixedKeyAliases(),
        session
      );
   
    if ( collectionRowKey != null ) {
      // we found a collection element in the result set

      if ( log.isDebugEnabled() ) {
        log.debug(
            "found row of collection: " +
            MessageHelper.collectionInfoString( persister, collectionRowKey, getFactory() )
          );
      }

      Object owner = optionalOwner;
      if ( owner == null ) {
        owner = persistenceContext.getCollectionOwner( collectionRowKey, persister );
        if ( owner == null ) {
          //TODO: This is assertion is disabled because there is a bug that means the
          //    original owner of a transient, uninitialized collection is not known
          //    if the collection is re-referenced by a different object associated
          //    with the current Session
          //throw new AssertionFailure("bug loading unowned collection");
        }
      }

      PersistentCollection rowCollection = persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, collectionRowKey );

      if ( rowCollection != null ) {
        rowCollection.readFrom( rs, persister, descriptor, owner );
      }

    }
    else if ( optionalKey != null ) {
      // we did not find a collection element in the result set, so we
      // ensure that a collection is created with the owner's identifier,
      // since what we have is an empty collection

      if ( log.isDebugEnabled() ) {
        log.debug(
            "result set contains (possibly empty) collection: " +
            MessageHelper.collectionInfoString( persister, optionalKey, getFactory() )
          );
      }

      persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, optionalKey ); // handle empty collection

    }
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

      else {

        CollectionCacheEntry cacheEntry = (CollectionCacheEntry) persister.getCacheEntryStructure()
            .destructure(ce, factory);
     
        final PersistenceContext persistenceContext = source.getPersistenceContext();
        cacheEntry.assemble(
            collection,
            persister, 
            persistenceContext.getCollectionOwner(id, persister)
          );
        persistenceContext.getCollectionEntry(collection).postInitialize(collection);
        //addInitializedCollection(collection, persister, id);
        return true;
      }
     
    }
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

   
    //postDelete:
    // After actually deleting a row, record the fact that the instance no longer
    // exists on the database (needed for identity-column key generation), and
    // remove it from the session cache
    final PersistenceContext persistenceContext = session.getPersistenceContext();
    EntityEntry entry = persistenceContext.removeEntry( instance );
    if ( entry == null ) {
      throw new AssertionFailure( "possible nonthreadsafe access to session" );
    }
    entry.postDelete();

    EntityKey key = new EntityKey( entry.getId(), entry.getPersister(), session.getEntityMode() );
    persistenceContext.removeEntity(key);
    persistenceContext.removeProxy(key);
   
    if ( persister.hasCache() ) persister.getCacheAccessStrategy().remove( ck );

    postDelete();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.