ejb

Is there a means by which to configure Hibernate Dialect Based on jta-data-source?

ぃ、小莉子 提交于 2020-01-04 13:43:21
问题 Assuming an ejb-jar with the following persistence.xml configuration: <?xml version="1.0" encoding="UTF-8"?> <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_2_0.xsd" version="2.0"> <persistence-unit name="com.mystrotv.mdn.admanager.entity"> <jta-data-source>/dataSource/MystroDS_Tx</jta-data-source> <properties>

How to build JPQL queries when parameters are dynamic?

好久不见. 提交于 2020-01-04 09:21:52
问题 I wonder if there is a good solution to build a JPQL query (my query is too "expressive" and i cannot use Criteria) based on a filter. Something like: query = "Select from Ent" if(parameter!=null){ query += "WHERE field=:parameter" } if(parameter2!=null) { query += "WHERE field2=:parameter2" } But i would write WHERE twice!! and the casuistic explodes as the number of parameter increases. Because none or all could be null eventually. Any hint to build these queries based on filters on a

EJB Timer when redepolyed in a cluster environement of Websphere Application Server

若如初见. 提交于 2020-01-04 07:03:27
问题 I have an .ear file which is composed of multiple EJB's and one of them do use a timer service to create timer and the same ejb has the callback method too. That ear is supposed to be deployed in a clustered environment of 3 servers. The issue now is that i want to know what is the expected behavior if i redeployed/undeployed the ear in the cluster. Will the server cancel all timers and clear the persistent scheduler? Or it will preserve them? What are the work arounds? I have read that in

EJB Interceptors and transaction lifecycle OR how to intercept a commit/failure event?

好久不见. 提交于 2020-01-04 07:01:06
问题 I have an EJB interceptor and I follow the BCE pattern suggested by Adam Bien, that is, all EJB calls on the boundary starts and finish a transaction which means there is no nested EJB calls (there might be nested CDI injected Bean calls though, but those should be inside the same transaction started at the ejb Boundary). So in those ejb Boundaries I have an interceptor and I want to intercept or know if after the method call of the EJB the transacction commited already? (that is, if a

EJB Interceptors and transaction lifecycle OR how to intercept a commit/failure event?

可紊 提交于 2020-01-04 07:01:00
问题 I have an EJB interceptor and I follow the BCE pattern suggested by Adam Bien, that is, all EJB calls on the boundary starts and finish a transaction which means there is no nested EJB calls (there might be nested CDI injected Bean calls though, but those should be inside the same transaction started at the ejb Boundary). So in those ejb Boundaries I have an interceptor and I want to intercept or know if after the method call of the EJB the transacction commited already? (that is, if a

How to use custom Exception in Session Beans?

浪子不回头ぞ 提交于 2020-01-04 05:35:07
问题 EJB 3.1 Session Bean: import javax.ejb.*; public class FooException extends EJBException { } @Stateless @Local public class Foo { public void bar() throws FooException { if (/* something wrong */) { throw new FooException(); } } } Now the test: import org.junit.*; public class FooTest { @Test(expected = FooException.class) public void testException() { new InitialContext().lookup("Foo").bar(); } } The problem is that EJBException is caught in the test, not FooException . Looks like EJB

@Schedule annotation in Java EE

丶灬走出姿态 提交于 2020-01-04 02:57:29
问题 I use the following annotation to call a stateless session bean once a 5 minutes: @Schedule(second = "0", minute = "0/5", hour = "*") I works as expected, except it stops itself after a few days. I guess there may be a default lifetime and I do not know how to override it. Please help me to configure the scheduler to run indefinitely. 回答1: to know if there is expiration date for your object you can use getTimers() to return an object of that timer then use this method getTimeRemaining() to

What is a real use-case for @Stateless over @Singleton in EJB

早过忘川 提交于 2020-01-03 17:48:13
问题 if I understand EJB correctly, @Singleton is actually the same as Singleton in plain Java and also singleton in spring -> one instance, every call goes through the same instance concurrently. @Stateless declares a bean, that could (but must not) have multiple instance, with the limitation that only one call can be in an instance at the same time. Right sofar? This remains me on the servlet programming model: in theory servlet containers are allowed to make multiple copies of the servlet, in

WELD-001408 Unsatisfied dependencies

随声附和 提交于 2020-01-03 17:06:18
问题 I have a very famous error, but I can't solve it. I'm trying to run arqullian test for my application. I've done everything according to the official documentation. The long search for solution to the problem given nothing. 16:49:42,713 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."test.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".WeldService: org.jboss.weld.exceptions

How do i set the Transaction Isolation in EJB?

为君一笑 提交于 2020-01-03 16:55:08
问题 I am not able to find a way to set TransactionIsolation in ejb. Can anybody tell me how do i set it? I am using persistence. I have looked the following classes : EntityManager , EntityManagerFactory, UserTransaction. None of them seems to have any method like setTransactionIsolation or such. Do we need to change persistence.xml? I just read a book named Mastering EJB 3.0 4th edition. They gave a full 10 page theory about Isolation level that this problems occur and that occurs and such