ejb-3.0

Inheriting class annotations

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 03:50:10
问题 Is there a way to make classes inherit annotations from a superclass ? e.g. @ApplicationException(rollback=true) public abstract class AbstractBeanActionException extends Exception { /* method body is simply calls to super() */ } public class OrderBeanException extends AbstractBeanActionException { /* does this class have to be annotated as well ? */ } 回答1: Class annotations can not be inherited by subclasses. What you can do is "force" the subclass to use the annotation at compile time:

Relationship between EJB 3.0 and JPA?

淺唱寂寞╮ 提交于 2019-12-30 00:54:10
问题 That may seem obvious but I've seen contradictory statements: Is JPA part of EJB 3.0? I'm no specialist and it's quite confusing for me. If so, JPA manipulates Entity Beans? These entity beans being the interface between the persistence layer and the business layer implementing the logic with stateless beans? The underlying question for me is how to implement a "search for user based on various criteria" function, where the "search" request -its string representation- should be built? I mean,

JavaEE 6: javax.naming.NameAlreadyBoundException: Use rebind to override

為{幸葍}努か 提交于 2019-12-29 06:45:37
问题 I have a business interface being implemented by two EJBs. UserManagementService @Remote public interface UserManagementService { // ... } UserManagementServiceJpaImpl @Stateless(name="userManagementServiceJpaImpl") public class UserManagementServiceJpaImpl implements UserManagementService { @EJB(beanName="userManagementDaoJpaImpl") private UserManagementDao userManagementDao; // ... } UserManagementServiceMockImpl @Stateless(name="userManagementServiceMockImpl") public class

logback with EJB3.1

▼魔方 西西 提交于 2019-12-29 06:23:11
问题 I am using logback/slf4j to handle logging in my application. Everything was working perfectly until I started using EJBs. Once I added a stateless EJB to my app, the logger started ignoring my logback.xml and stopped using my appenders. I switched to a programmatic logger configuration to see what was wrong and now I am getting the following error when I try to use my logger within the EJB: org.slf4j.impl.JDK14LoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext stemming from

Understanding EJB3/JPA container-level transactions and isolation level

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 04:24:16
问题 Consider this simplified view of some code with which I'm working: @Stateless(...) @Remote(...) @TransactionAttribute(TransactionAttributeType.MANDATORY) public class FirstEjbType { @EJB(...) private SecondEjbType secondEjb; @EJB(...) private ThirdEjbType thirdEjb; public void doSomething() { secondEjb.doSomething(); // WRITES SOMETHING TO THE DATABASE thirdEjb.doSomething(); // CAN'T SEE THAT SOMETHING IN THE DATABASE! } I've set the TransactionAttribute annotation to MANDATORY at the class

Error with JPA transaction when calling a stored procedure

China☆狼群 提交于 2019-12-25 07:57:54
问题 I have a stored procedure in an Oracle DB, which I wish to call from my EJB AS (websphere) using the following JPA code. The procedure includes some "COMMIT" in its body. The point is that when I remove the COMMIT of the procedure, JPA is able to invoque the procedure correctly. If I leave the COMMIT then I get an exception telling me that the call cannot be executed. The java code is placed in a session bean with the transaction set up as REQUIRED by default. public void updateProc() { Query

'no session or session was closed' with JPA 2 and EJB 3.1

你说的曾经没有我的故事 提交于 2019-12-25 06:49:56
问题 I have stateless session bean with this method: @Override public List<Character> getUserCharacters(int userId) { User user = em.find(User.class, userId); if(user != null) return user.getCharacters(); else return null; } where User class if defined in this way: @Entity @Table(name="Users") public class User implements Serializable{ /** */ private static final long serialVersionUID = 8119486011976039947L; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) private int id; @ManyToMany(fetch

How does client know the EJB bean implementation is remote or local in ejb3

眉间皱痕 提交于 2019-12-25 05:24:29
问题 I'm a newbie to EJB3. I want to know that how client know the EJB bean implementation is in remote or local. When i access the bean using InitialContext in client class i want to know wether that bean is local or remote? Sorry if I'm asking stupid question? 回答1: The type of interface is determined via annotations. These can be put next to Interface class declaration: @Local - declares a local business interface @Remote - declares a remote business interface Then when an EJB extends such

Change Activation-Config-Property on deployment via JBoss CLI

断了今生、忘了曾经 提交于 2019-12-25 05:12:11
问题 We would like to deploy an EAR containing message driven beans with JBoss CLI. For each environment there are different activation config property values. Our question: is it possible to change the values of the activation config properties after deploying the EAR with JBoss CLI? We know we could use property substitution. However this seems to set the activation properties at server startup. In contrast we would like to change the values at any time (maybe as long as application is disabled)

How to eagerly fetch a single “default” entity from a collection in EJB3/JPA

眉间皱痕 提交于 2019-12-25 04:34:18
问题 I have a Person entity with multiple phone numbers. @OneToMany(mappedBy="person", cascade=CascadeType.ALL) public Set<PhoneNumberOfPerson> getPhoneNumbers() { return phoneNumbers; } Now I would like to implement a "get default phone number" method for Person that is eagerly fetched. This default phone number is one of the phone numbers in the phoneNumbers set. Is there any way to do this? The reason I'm trying to implement this is to have this default phone number listed on a page that lists