Package javax.persistence

Examples of javax.persistence.EntityManager.find()


                Host_Descriptor existingHostDesc = em.find(Host_Descriptor.class, new Host_Descriptor_PK(gatewayName, name.toString()));
                em.close();
                return existingHostDesc != null;
            case SERVICE_DESCRIPTOR:
                em = ResourceUtils.getEntityManager();
                Service_Descriptor existingServiceDesc = em.find(Service_Descriptor.class, new Service_Descriptor_PK(gatewayName, name.toString()));
                em.close();
                return existingServiceDesc != null;
            case APPLICATION_DESCRIPTOR:
                em = ResourceUtils.getEntityManager();
                Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name.toString()));
View Full Code Here


                Service_Descriptor existingServiceDesc = em.find(Service_Descriptor.class, new Service_Descriptor_PK(gatewayName, name.toString()));
                em.close();
                return existingServiceDesc != null;
            case APPLICATION_DESCRIPTOR:
                em = ResourceUtils.getEntityManager();
                Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name.toString()));
                em.close();
                return existingAppDesc != null;
            case EXPERIMENT:
                em = ResourceUtils.getEntityManager();
                Experiment existingExp = em.find(Experiment.class, name.toString());
View Full Code Here

                Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name.toString()));
                em.close();
                return existingAppDesc != null;
            case EXPERIMENT:
                em = ResourceUtils.getEntityManager();
                Experiment existingExp = em.find(Experiment.class, name.toString());
                em.close();
                return existingExp != null;
            default:
                logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
                throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
View Full Code Here

     * @param id the id of the object to remove
     * @throws WebloggerException on any error deleting object
     */
    public void remove(Class clazz, String id) throws WebloggerException {
        EntityManager em = getEntityManager(true);
        Object po = em.find(clazz, id);
        em.remove(po);
    }
   
    /**
     * Remove object from persistence storage.
View Full Code Here

     * @throws WebloggerException on any error retrieving object
     */
    public Object load(Class clazz, String id)
    throws WebloggerException {
        EntityManager em = getEntityManager(false);
        return em.find(clazz, id);
    }
   
    /**
     * Return true if a transaction is active on the current EntityManager.
     * @param em the persistence manager
View Full Code Here

    em.clear();
    getTransactionManager().begin();
    operationSuccessful = false;
    try {
      Bridge news = em.find( Bridge.class, 1L );
      assertThat( news ).isNotNull();
      assertThat( news.getName() ).isEqualTo( "Bixby Creek Bridge" );

      em.remove( news );
      assertThat( em.find( Bridge.class, 1L ) ).isNull();
View Full Code Here

      Bridge news = em.find( Bridge.class, 1L );
      assertThat( news ).isNotNull();
      assertThat( news.getName() ).isEqualTo( "Bixby Creek Bridge" );

      em.remove( news );
      assertThat( em.find( Bridge.class, 1L ) ).isNull();
    }
    finally {
      commitOrRollback( operationSuccessful );
    }
View Full Code Here

    em.clear();
    getTransactionManager().begin();
    operationSuccessful = false;

    try {
      Bridge loadedBridge = em.find( Bridge.class, 3L );
      assertThat( loadedBridge ).isNotNull();
      assertThat( loadedBridge.getEngineers() ).onProperty( "name" ).containsOnly( "Bruce the initializer" );
      em.remove( loadedBridge );
      assertThat( em.find( Bridge.class, 3L ) ).isNull();
View Full Code Here

    try {
      Bridge loadedBridge = em.find( Bridge.class, 3L );
      assertThat( loadedBridge ).isNotNull();
      assertThat( loadedBridge.getEngineers() ).onProperty( "name" ).containsOnly( "Bruce the initializer" );
      em.remove( loadedBridge );
      assertThat( em.find( Bridge.class, 3L ) ).isNull();

      loadedBridge = em.find( Bridge.class, 2L );
      assertThat( loadedBridge ).isNotNull();
      assertThat( loadedBridge.getEngineers() ).onProperty( "name" ).containsOnly( "Bob the constructor", "Biff the destructor" );
      em.remove( loadedBridge );
View Full Code Here

      assertThat( loadedBridge ).isNotNull();
      assertThat( loadedBridge.getEngineers() ).onProperty( "name" ).containsOnly( "Bruce the initializer" );
      em.remove( loadedBridge );
      assertThat( em.find( Bridge.class, 3L ) ).isNull();

      loadedBridge = em.find( Bridge.class, 2L );
      assertThat( loadedBridge ).isNotNull();
      assertThat( loadedBridge.getEngineers() ).onProperty( "name" ).containsOnly( "Bob the constructor", "Biff the destructor" );
      em.remove( loadedBridge );
      assertThat( em.find( Bridge.class, 2L ) ).isNull();
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.