entitymanager

java.lang.IllegalArgumentException: Named query not found:

戏子无情 提交于 2019-12-10 17:30:54
问题 I got the following code @Stateless public class BondecomandeDAO { @PersistenceContext private EntityManager em; public Bondecommande findBCbyid(int id) { Query q =em.createNamedQuery("select bc from Bondecommande bc where bc.idbc = :idbc"); q.setParameter("idbc", id); return (Bondecommande) q.getResultList().get(0); } } and @Entity @Table(name="bondecommande") public class Bondecommande implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy =

Problem creating JPA EntityMananger in Spring Context

不打扰是莪最后的温柔 提交于 2019-12-10 17:29:51
问题 I have a JPA/Spring application that uses Hibernate as the JPA provider. In one portion of the code, I have to manually create a DAO in my application with the new operator rather than use Spring DI. When I do this, the @PersistenceContext annotation is not processed by Spring. In my code where I create the DAO I have an EntityManagerFactory which I used to set the entityManager as follows: @PersistenceUnit private EntityManagerFactory entityManagerFactory; MyDAO dao = new MyDAOImpl(); dao

Injecting EntityManager using Spring ( Null Pointer Exception ) [duplicate]

我的梦境 提交于 2019-12-10 14:42:41
问题 This question already has answers here : Why is my Spring @Autowired field null? (16 answers) Closed 3 years ago . Here's the code insidy my ApplicationContext.xml <context:spring-configured /> <context:annotation-config /> <context:component-scan base-package="com.apsas.jpa" /> <tx:annotation-driven /> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="testjpa" /> </bean> <bean id="entityManager"

No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call

半腔热情 提交于 2019-12-10 13:46:42
问题 No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call when I do a test with JUnit, persist method works and I see that my object is inserted, but when I call the method via my Controller doesn't work here is my Project : applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework

javax.ejb.EJBException when persisting an entity

。_饼干妹妹 提交于 2019-12-10 13:32:30
问题 I have an entity called Medico which was created as an Entity Class from Database, hence I think the entity definition is failsafe here, nevertheless the definition is the following: @Entity @Table(name = "medico") @XmlRootElement @NamedQueries({All named queries here}) public class Medico implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @NotNull @Column(name = "idMedico") private

No transactional EntityManager available - working with JPA Api, error with Hibernate Session

浪尽此生 提交于 2019-12-10 13:07:17
问题 I am trying to unwrap the Hibernate Session from injected EntityManager, as I need to use Hibernate's native Criteria API. When I try to use Criteria i get following exception: Caused by: java.lang.IllegalStateException: No transactional EntityManager available at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:224) at com.sun.proxy.$Proxy28.unwrap(Unknown Source) at sk.uniba.ais2.fajr.dao.impl

Symfony2 inject EntityMananager in FormType

∥☆過路亽.° 提交于 2019-12-10 12:05:42
问题 Custom form type use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Doctrine\ORM\EntityManager; class NationaliteitidType extends AbstractType { private $doctrine; private $em; public function __construct(EntityManager $em) { $this->em = $em; } service.yml services: fw_core.form.type: class: FW\CoreBundle\Form

New EntityManager sometimes getting stale data from MySQL

寵の児 提交于 2019-12-10 11:14:45
问题 JPA; Hibernate 4.3.6; MySQL 6.2 (InnoDB); Vaadin web application running on Tomcat When I read an entity from the database I sometimes get stale data. I can’t find the pattern— sometimes the same code pulls stale data, then clean data, then stale again. I am getting a new EntityManager before each query. (I was concerned that I might be somehow getting them from a pool of reused EntityManagers, but flushing the “new” EntityManager gives me an error that no transaction is in progress.)

JPA 1.0 error: The name is not a recognized entity or identifier. Known entity names: []

◇◆丶佛笑我妖孽 提交于 2019-12-10 07:42:32
问题 I am getting following exception while I try to execute simple JPA 1.0 code. What may be the cause? 5453 DevPQRWDPBSSPersist WARN [P=351601:O=0:CT] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "[class com.XYZ.PQR.bss.client.db.data.markerentry, class com.XYZ.PQR.bss.client.db.data.Serviceproduct, class com.XYZ.PQR.bss.client.db.data.Agreementterms, class com.XYZ.PQR

Where to place @SqlResultSetMapping in case of @ConstructorResult

不想你离开。 提交于 2019-12-10 02:58:52
问题 I'm trying to map a non-entity pojo with the createNativeQuery method of entityManager of jpa. By using something like this @SqlResultSetMapping(name="ResultMapping", classes={ @ConstructorResult( targetClass=Employee.class, columns={ @ColumnResult(name="empID", type=Long.class), @ColumnResult(name="empName", type=String.class), } ) } ) public class Loader{ private EntityManager em; public void load(){ Query query = em.createNativeQuery("select empID, empName from employee", "ResultMapping");