Package javax.persistence

Examples of javax.persistence.EntityManager.createNativeQuery()


     */
    protected void deleteAllData() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        em.createNativeQuery("delete from Supplier_Part").executeUpdate();
        em.createQuery("delete from PartBase s").executeUpdate();
        em.createQuery("delete from Supplier s").executeUpdate();
        em.createQuery("delete from Usage u").executeUpdate();
        em.createQuery("delete from Part p").executeUpdate();

View Full Code Here


        em.getTransaction().begin();

        String insert1 =
            "insert into Part(partno,parttype,name,cost,mass)" +
            " values(13,'PartBase','breakes',1000.0,100.0)";
        em.createNativeQuery(insert1).executeUpdate();
        String insert2 =
            "insert into Supplier_Part(suppliers_sid,supplies_partno)" +
            " values(1,13)";
        em.createNativeQuery(insert2).executeUpdate();
View Full Code Here

            " values(13,'PartBase','breakes',1000.0,100.0)";
        em.createNativeQuery(insert1).executeUpdate();
        String insert2 =
            "insert into Supplier_Part(suppliers_sid,supplies_partno)" +
            " values(1,13)";
        em.createNativeQuery(insert2).executeUpdate();

        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
View Full Code Here

        em = emf.createEntityManager();
        em.getTransaction().begin();

        String sql = "select partno from Part where cost > 120 ";
        Query nativeq = em.createNativeQuery(sql);
        int nativelistSize = nativeq.getResultList().size();

        em.getTransaction().commit();
        em.close();
View Full Code Here

    }
   
    public void testNativeSQL() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        int count = em.createNativeQuery("INSERT INTO Address (id, city,"
          + " country, streetAd, zipcode) VALUES (?,?,?,?,?)")
          .setParameter(1, System.currentTimeMillis()%10000)
          .setParameter(2, "Some City")
          .setParameter(3, "Some Country")
          .setParameter(4, "Some Street")
View Full Code Here

    }
   
    public int setSequence(long sequence) {
        int result = 0;
        EntityManager em = emf.createEntityManager();
        Query query = em.createNativeQuery("update SEQUENCE set SEQ_COUNT = ?1");
        query.setParameter(1, sequence);
        em.getTransaction().begin();
        try {
            result = query.executeUpdate();
            em.getTransaction().commit();
View Full Code Here

    }
   
    public int setSequence(long sequence) {
        int result = 0;
        EntityManager em = emf.createEntityManager();
        Query query = em.createNativeQuery("update SEQUENCE set SEQ_COUNT = ?1");
        query.setParameter(1, sequence);
        em.getTransaction().begin();
        try {
            result = query.executeUpdate();
            em.getTransaction().commit();
View Full Code Here

    }
   
    private void setH2LockTimeout() {
        EntityManager manager = entityManagerFactory.createEntityManager();
        manager.getTransaction().begin();
        manager.createNativeQuery("SET DEFAULT_LOCK_TIMEOUT " + locktimeout).executeUpdate();
        manager.getTransaction().commit();
        manager.close();
    }
   
    @After
View Full Code Here

    public void clear() throws LocomotivePersistenceException {
        logger.debug("clear()");
        EntityManager em = HibernatePersistence.getEntityManager();
        try {
            em.createNativeQuery("TRUNCATE TABLE locomotive").executeUpdate();
            // em.createNativeQuery("TRUNCATE TABLE locomotive_type")
            // .executeUpdate();
            em.createNativeQuery("TRUNCATE TABLE locomotive_group")
                    .executeUpdate();
View Full Code Here

        EntityManager em = HibernatePersistence.getEntityManager();
        try {
            em.createNativeQuery("TRUNCATE TABLE locomotive").executeUpdate();
            // em.createNativeQuery("TRUNCATE TABLE locomotive_type")
            // .executeUpdate();
            em.createNativeQuery("TRUNCATE TABLE locomotive_group")
                    .executeUpdate();

            super.clear();

            em.getTransaction().commit();
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.