ejb-3.0

EJB/JPA Transaction Boundaries

情到浓时终转凉″ 提交于 2021-02-18 11:17:10
问题 I was reading EJB Transaction boundary and Transaction boundary Lets concentrate on RequiresNew Attribute . Here is the modified diagram from the link So let say method-B is annotated with RequiredNew attribute . so according to theory when method-A calls method-B a new transaction will be start and the already started transaction will be suspended, and when method-B returns the new transaction will be committed. Now consider that in section S1 we create a jpa entity using entitymanager

Bean Transaction Timeout in WebSphere using EJB Timer

依然范特西╮ 提交于 2021-02-07 13:38:51
问题 With JBoss/Wildfly one is able to use the @TransactionTimeout proprietary annotation and define a transaction timeout for a specific Session Bean. What is the equivalent way of doing it using IBM WebSphere ? We are using EJB Timer and one of the Beans will over an hour to complete. Sample code for Wildfly: import org.jboss.ejb3.annotation.TransactionTimeout; @Stateless @TransactionTimeout(value=7200) public class TimerBean { } Note: Using WebSphere 8.5. Modifying the global transaction time

Bean Transaction Timeout in WebSphere using EJB Timer

梦想与她 提交于 2021-02-07 13:38:36
问题 With JBoss/Wildfly one is able to use the @TransactionTimeout proprietary annotation and define a transaction timeout for a specific Session Bean. What is the equivalent way of doing it using IBM WebSphere ? We are using EJB Timer and one of the Beans will over an hour to complete. Sample code for Wildfly: import org.jboss.ejb3.annotation.TransactionTimeout; @Stateless @TransactionTimeout(value=7200) public class TimerBean { } Note: Using WebSphere 8.5. Modifying the global transaction time

Java EE 5 dependency injection?

99封情书 提交于 2021-02-07 06:17:21
问题 Since Java EE 5 does not have CDI, how does DI work in here? Can an EJB be injected with @EJB in a class that is a non-EJB? Can an EntityManager be injected with @PersistenceContext in a class that is a non-EJB (container managed not resource local EntityManager )? Or the only solution to bring the resources in non-EJB classes is by JNDI lookup? By non-EJB class I mean a class that is not annotated with @Stateless / @Statefull or others. 回答1: Taken from: http://www.oracle.com/technetwork

How can I avoid the Warning “firstResult/maxResults specified with collection fetch; applying in memory!” when using Hibernate?

百般思念 提交于 2020-05-12 07:30:08
问题 I'm getting a warning in the Server log "firstResult/maxResults specified with collection fetch; applying in memory!" . However everything working fine. But I don't want this warning. My code is public employee find(int id) { return (employee) getEntityManager().createQuery(QUERY).setParameter("id", id).getSingleResult(); } My query is QUERY = "from employee as emp left join fetch emp.salary left join fetch emp.department where emp.id = :id" 回答1: Reason for this warning is that when fetch

Generate constants for class attributes with maven?

放肆的年华 提交于 2020-02-22 21:02:29
问题 i have a small code generation question. I have a EJB3 backend that serves DTO objects to a frontend. The frontend uses a configurable binding procedure to map the attributes of the DTO to their forms. At the moment they are doing it by specifing the attributes as strings in ther configuration. The binding implementation uses reflection to acces the attributes. Sounds nice but the problem is, each time we change an attribute name in a DTO, this will not lead to a compile error in the frontend

why pool stateless bean?

拥有回忆 提交于 2020-02-02 06:36:20
问题 Normally we use singleton instance for business / dao layer. What is the reason behind pooling stateless session beans in case of EJBs? 回答1: The "stateless" in the name refers to session conversation state, i.e. state that persists between invocations of the bean, retained for the duration of the session. However, stateless session beans are still permitted to have instance variables. Those instance variables should not relate to the conversation state, but are "shared" between clients. In

LockMode in EJB3 Persistence NamedQuery

淺唱寂寞╮ 提交于 2020-01-25 09:10:08
问题 How do we specify LockMode in EJB3 Persistence NamedQuery? I want to add Pessimistic LockMode to my existing select so that I can update if necessary but surprisingly Query object doesnot have setLockMode(xxx) method ( My understanding was if JPA, asubset of EJB3 persistence, exposes setLockMode, EJB3 persistence should have the method available too). Query query = em.createNamedQuery("findOptoutStudent"); query.setParameter("optoutIndicator", optoutIndicator); List<Student> students = query

Stateful bean injecting stateless bean, will they both use the same instance of EntityManagerFactory?

核能气质少年 提交于 2020-01-25 07:18:48
问题 I have a Stateful Bean injecting a JPA PersistenceUnit and another stateless bean. The stateless bean is injecting the same PersistenceUnit as well. My question is, will the EJB container inject the same instance of PersistenceUnit in both beans. I have to be very sure about the behaviour here. @Stateful public class MyStatefulBean { @PersistenceUnit(unitName = "MY_PU") private EntityManagerFactory emf; @EJB MyStatelessLocal statelessEJB; public void doSomething() { // Question will

EntityManager injection results in NullPointerException

 ̄綄美尐妖づ 提交于 2020-01-23 02:42:45
问题 I'm writing my first Java EE (EJB + Servlets etc.) application (please note: I'm using Eclipse). I'm stuck with a problem with EntityManager injection not working, and having some difficulties finding why due to my Java EE (and Java in general) noobness. Here is my persistence.xml file - I think this is mostly correct, since I can launch the HSQL database manager from the JMX console and my PUBLIC.USER table shows up correctly. <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0"