@Test public void testPersistOrUpdatePersist() { assertTrue(penv.tx(TestDto.findAll).isEmpty()); final TestDto dto = penv.tx(Queries.persistOrUpdate(TestDto.create("key", "value"))); assertEquals("value", penv.tx(Queries.find(TestDto.class, dto.getId())).get().getValue()); dto.setValue("new-value"); penv.tx(Queries.persistOrUpdate(dto)); assertEquals("new-value", penv.tx(Queries.find(TestDto.class, dto.getId())).get().getValue()); }
@Deprecated public static <A, B> Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName, final Tuple<String, ?>... params) { return PersistenceUtil.<B> runSingleResultQuery(em, queryName, params).map(toA); }
PersistenceUtil { @Deprecated public static <A, B> Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName, final Tuple<String, ?>... params) { return PersistenceUtil.<B> runSingleResultQuery(em, queryName, params).map(toA); } }
PersistenceUtil { @Deprecated public static <A, B> Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName, final Tuple<String, ?>... params) { return PersistenceUtil.<B> runSingleResultQuery(em, queryName, params).map(toA); } private  PersistenceUtil(); }
PersistenceUtil { @Deprecated public static <A, B> Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName, final Tuple<String, ?>... params) { return PersistenceUtil.<B> runSingleResultQuery(em, queryName, params).map(toA); } private  PersistenceUtil(); static Option<EntityManager> createEntityManager(EntityManagerFactory emf); static PersistenceEnv2<F> equip2(final PersistenceEnv penv, final Function<Exception, F> exHandler); @Deprecated static PersistenceEnv newPersistenceEnvironment(final EntityManagerFactory emf); @Deprecated static Query createNamedQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static boolean runUpdate(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static Option<A> runSingleResultQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static Option<A> runFirstResultQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static long runCountQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static Function<EntityManager, Option<A>> findById(final Class<A> clazz, final Object primaryKey); @Deprecated static Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName,
          final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final String queryName, final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final String queryName, Option<Integer> offset,
          Option<Integer> limit, final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final Function<B, A> toA, final String queryName,
          final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final Function<B, A> toA, Option<Integer> offset,
          Option<Integer> limit, final String queryName, final Tuple<String, ?>... params); @Deprecated static Function<EntityManager, A> persist(final A a); @Deprecated static Function<EntityManager, A> merge(final A a); static EntityManagerFactory newEntityManagerFactory(String emName, String vendor, String driver, String url,
          String user, String pwd, Map<String, ?> persistenceProps, PersistenceProvider pp); static EntityManagerFactory newTestEntityManagerFactory(String emName); static PersistenceProvider testPersistenceProvider(); @Deprecated static PersistenceEnv newTestPersistenceEnv(String emName); }
PersistenceUtil { @Deprecated public static <A, B> Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName, final Tuple<String, ?>... params) { return PersistenceUtil.<B> runSingleResultQuery(em, queryName, params).map(toA); } private  PersistenceUtil(); static Option<EntityManager> createEntityManager(EntityManagerFactory emf); static PersistenceEnv2<F> equip2(final PersistenceEnv penv, final Function<Exception, F> exHandler); @Deprecated static PersistenceEnv newPersistenceEnvironment(final EntityManagerFactory emf); @Deprecated static Query createNamedQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static boolean runUpdate(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static Option<A> runSingleResultQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static Option<A> runFirstResultQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static long runCountQuery(EntityManager em, String queryName, Tuple<String, ?>... params); @Deprecated static Function<EntityManager, Option<A>> findById(final Class<A> clazz, final Object primaryKey); @Deprecated static Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName,
          final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final String queryName, final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final String queryName, Option<Integer> offset,
          Option<Integer> limit, final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final Function<B, A> toA, final String queryName,
          final Tuple<String, ?>... params); @Deprecated static List<A> findAll(EntityManager em, final Function<B, A> toA, Option<Integer> offset,
          Option<Integer> limit, final String queryName, final Tuple<String, ?>... params); @Deprecated static Function<EntityManager, A> persist(final A a); @Deprecated static Function<EntityManager, A> merge(final A a); static EntityManagerFactory newEntityManagerFactory(String emName, String vendor, String driver, String url,
          String user, String pwd, Map<String, ?> persistenceProps, PersistenceProvider pp); static EntityManagerFactory newTestEntityManagerFactory(String emName); static PersistenceProvider testPersistenceProvider(); @Deprecated static PersistenceEnv newTestPersistenceEnv(String emName);  }