entitymanager

EntityManager is null inside Pojo class in ejb container

橙三吉。 提交于 2020-01-06 15:02:07
问题 I have a Java web service module and ejb modulein netbeans (All part of an enterprise application). the web service is consuming the ejb class using @EJB injection. Inside the ejb module i have a TransactionManager class which is not an enterprise bean. just a POJO class. I am trying to inject the EntityManager using @PersistanceContext(unitName = "testPU") EntityManager em; but the em is allways null. I am calling the TransactionManager class from by bean, and if i declare the EntityManager

Hibernate NoSuchFieldError: INSTANCE

落爺英雄遲暮 提交于 2020-01-06 13:32:06
问题 I'm trying to integrate Hibernate Search with Spring Data JPA, so I wrote a sample code to test it. @PersistenceContext EntityManager em; @Override @Transactional public List<Place> findAll() { FullTextEntityManager fullTextSession = Search.getFullTextEntityManager(em); QueryBuilder builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Place.class).get(); double centerLatitude = 0d; double centerLongitude = 0d; org.apache.lucene.search.Query luceneQuery = builder .spatial

Hibernate NoSuchFieldError: INSTANCE

冷暖自知 提交于 2020-01-06 13:29:37
问题 I'm trying to integrate Hibernate Search with Spring Data JPA, so I wrote a sample code to test it. @PersistenceContext EntityManager em; @Override @Transactional public List<Place> findAll() { FullTextEntityManager fullTextSession = Search.getFullTextEntityManager(em); QueryBuilder builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Place.class).get(); double centerLatitude = 0d; double centerLongitude = 0d; org.apache.lucene.search.Query luceneQuery = builder .spatial

My EJB throws a transaction required exception although another EJB setup in the same way with same persistence unit throws no excpetion

随声附和 提交于 2020-01-06 07:16:33
问题 First here is my entire EJB file: package enkia.pulse.indexing.beans; import enkia.pulse.core.Category; import enkia.pulse.core.Product; import enkia.pulse.core.Review; import enkia.pulse.core.Twitter; import enkia.utils.HarvestingConstants; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Resource; import javax.ejb.SessionContext; import javax.ejb

How to get Container Managed Transactions (CMT) working with EJB 3.1, Hibernate 3.6, JPA 2.0 , JBoss and MySQL

狂风中的少年 提交于 2020-01-05 07:37:12
问题 I was trying to get CMT working with JPA EntityManagers and EJBs, but came up with the error below. (stack trance truncated): Caused by: java.lang.RuntimeException: **Could not resolve @EJB reference: [EJB Reference: beanInterface 'com.mydomain.beans.TestBean2', beanName 'testBean2', mappedName 'null', lookupName 'null',** owning unit 'AbstractVFSDeploymentContext@2008455195{vfs:///Users/willtardy/Documents/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.0_Runtime

when I am running test cases that time entity manager is injected successfully but while running web app its throwing NullPointerException

纵然是瞬间 提交于 2020-01-04 06:29:02
问题 I have a strange problem. I am injecting the entity manager using PersistenceContext using applicatioContext bean. But problem is that when I am running test cases that time entity manager is injected successfully but while running web app its throwing NullPointerException this is abstractRepository where I am injecting entityManager package com.ajit.retail.repository; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence

when I am running test cases that time entity manager is injected successfully but while running web app its throwing NullPointerException

只谈情不闲聊 提交于 2020-01-04 06:28:07
问题 I have a strange problem. I am injecting the entity manager using PersistenceContext using applicatioContext bean. But problem is that when I am running test cases that time entity manager is injected successfully but while running web app its throwing NullPointerException this is abstractRepository where I am injecting entityManager package com.ajit.retail.repository; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence

EntityManager throws TransactionRequiredException on merge() in JBoss JSF bean

孤者浪人 提交于 2020-01-03 08:53:58
问题 I've set up a JSF application on JBoss 5.0.1GA to present a list of Users in a table and allow deleting of individual users via a button next to each user. When deleteUser is called, the call is passed to a UserDAOBean which gets an EntityManager injected from JBoss. I'm using the code public void delete(E entity) { em.remove(em.merge(entity)); } to delete the user (code was c&p from a JPA tutorial). Just calling em.remove(entity) has no effect and still causes the same exception. When this

EclipseLink, EntityManager with two persistence units needed

て烟熏妆下的殇ゞ 提交于 2020-01-01 16:58:29
问题 I have one jar library A (or project in eclipse), which has it's own persistence unit (META-INF/persistence.xml) and some entity classes, and another project (B) using this one. In project B there is also persistence unit and entity classes. In project B I need to use both entity classes from project A and B. But if I set "A" as persistence unit name, EntityManager cannot create named query if this query is in entity from project B. If I set "B" as persistence unit name, it cannot create

When using JPA entityManager why do you have to merge before you remove?

▼魔方 西西 提交于 2020-01-01 08:53:41
问题 For a while now I have been wondering why when using JPA, do I have to write my delete methods like this: @Transactional public void delete(Account account) { if (entityManager.contains(account)) { entityManager.remove(account); } else { entityManager.remove(entityManager.merge(account)); } } Perhaps the contains isn't needed since the transaction begins and ends with this method, but I still wonder why the remove couldn't just take an unmanaged object. Is it because it needs to be managed in