entitymanager

Symfony2: how to get all entities of one type which are marked with “EDIT” ACL permission?

允我心安 提交于 2019-12-03 08:10:38
问题 Can someone tell me how to get all entities of one type which are marked with "EDIT" ACL permission? I would like to build a query with the Doctrine EntityManager. 来源: https://stackoverflow.com/questions/6201279/symfony2-how-to-get-all-entities-of-one-type-which-are-marked-with-edit-acl-p

When to use Entity Manager in Symfony2

↘锁芯ラ 提交于 2019-12-03 07:15:41
问题 At the moment I am learning how to use Symfony2. I got to the point where they explain how to use Doctrine. In the examples given they sometimes use the entity manager: $em = $this->getDoctrine()->getEntityManager(); $products = $em->getRepository('AcmeStoreBundle:Product') ->findAllOrderedByName(); and in other examples the entity manager is not used: $product = $this->getDoctrine() ->getRepository('AcmeStoreBundle:Product') ->find($id); So I actually tried the first example without getting

Is PersistenceAnnotationBeanPostProcessor of any use at all?

纵然是瞬间 提交于 2019-12-03 05:13:57
问题 According to its JavaDoc, PersistenceAnnotationBeanPostProcessor seems to be responsible for injecting the EntityManager with the annotation @PersistenceContext. It appears to imply without this bean declared in the Spring application context xml, the @PersistenceContext annotation won't work. However, based on my experiments, this is not the truth. Persistence.xml <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi

What is exact purpose of flush in JPA

本小妞迷上赌 提交于 2019-12-03 03:01:53
Some confusing explanation: flush(); Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.it will update or insert into your tables in the running transaction, but it may not commit those changes. If the changes are anyways going to be persisted in the database only after the commit then why to flush in the middle of the code. And after running the flush if any changes are made to the managed object then will that throw an Exception or will those get synchronized and then will get perisisted. If they get synchronized then again why

JPA merge vs. persist

≡放荡痞女 提交于 2019-12-03 01:34:03
问题 So far, my preference has been to always use EntityManager's merge() take care of both insert and update. But I have also noticed that merge performs an additional select queries before update/insert to ensure record does not already exists in the database. Now that I am working on a project requiring extensive (bulk) inserts to the database. From a performance point of view does it make sense to use persist instead of merge in a scenario where I absolutely know that I am always creating a

EJB: Using EntityManager in PostConstruct method

偶尔善良 提交于 2019-12-03 01:32:15
After constructing the bean, I want to retrieve data from the database, using the EntityManager. It is not possible in the constructor, because the EntityManager is injected after the constructor is called. So I tried to do it in a method annotated with @PostConstruct. According to the API, a PostConstruct Methods gets called after all injection are done. Executing the query works, but it always returns an empty list. If I use the same query in an other method, it returns the correct result. Does anybody know, why it does not work in the PostConstruct method? @Stateful(mappedName = "price")

Symfony2: how to get all entities of one type which are marked with “EDIT” ACL permission?

那年仲夏 提交于 2019-12-02 23:25:43
Can someone tell me how to get all entities of one type which are marked with "EDIT" ACL permission? I would like to build a query with the Doctrine EntityManager. 来源: https://stackoverflow.com/questions/6201279/symfony2-how-to-get-all-entities-of-one-type-which-are-marked-with-edit-acl-p

When to use Entity Manager in Symfony2

一世执手 提交于 2019-12-02 21:58:57
At the moment I am learning how to use Symfony2. I got to the point where they explain how to use Doctrine. In the examples given they sometimes use the entity manager: $em = $this->getDoctrine()->getEntityManager(); $products = $em->getRepository('AcmeStoreBundle:Product') ->findAllOrderedByName(); and in other examples the entity manager is not used: $product = $this->getDoctrine() ->getRepository('AcmeStoreBundle:Product') ->find($id); So I actually tried the first example without getting the entity manager: $repository = $this->getDoctrine() ->getRepository('AcmeStoreBundle:Product');

Is PersistenceAnnotationBeanPostProcessor of any use at all?

試著忘記壹切 提交于 2019-12-02 18:31:00
According to its JavaDoc, PersistenceAnnotationBeanPostProcessor seems to be responsible for injecting the EntityManager with the annotation @PersistenceContext. It appears to imply without this bean declared in the Spring application context xml, the @PersistenceContext annotation won't work. However, based on my experiments, this is not the truth. Persistence.xml <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

JPA merge vs. persist

醉酒当歌 提交于 2019-12-02 15:03:05
So far, my preference has been to always use EntityManager's merge() take care of both insert and update. But I have also noticed that merge performs an additional select queries before update/insert to ensure record does not already exists in the database. Now that I am working on a project requiring extensive (bulk) inserts to the database. From a performance point of view does it make sense to use persist instead of merge in a scenario where I absolutely know that I am always creating a new instance of objects to be persisted? Óscar López It's not a good idea using merge when a persist