ejb-3.0

How to apply a default-restriction on Entity-Bean @OneToMany Relationships

大城市里の小女人 提交于 2019-12-22 10:05:52
问题 I have two entity models, Customer and Order. Each customer could have thousands of orders. I have a OneToMany and ManyToOne relationship between these two entities. How do I restrict this relationship's list to only top 10 orders? Is it possible to apply 'WHERE' condition as an attribute on @OneToMany or not? Like: @OneToMany("Where Order.orderNo > 100") My problem is when the object created by Entity Manager all Orders are created in memory. Lazy loading can not solve my consideration,

EJB Glassfish v3.1.2 client passed data to session bean is always null

本小妞迷上赌 提交于 2019-12-22 09:45:31
问题 I am having a problem when calling session bean method passing method parameters from client application, the data reaches the method call is always null or set to default value. while the process of the method works well with the object for example: -we have method to persist an object entity addStudent(Student student); - from the client we create the student object setting student fields like student name and so on, calling the method addStudent(ourStudent); this ourStudent reaches method

How to specify a different jndi-name than the default for an EJB in JBoss 4.2.2.GA?

試著忘記壹切 提交于 2019-12-22 09:24:53
问题 By default it seems the jndi name of a bean is based on the ear in which it is contained. An EJB named MyBean my-app.ear will have the name "my-app/MyBean/local". How can I change that behavior declaratively? I want the jndi name to be "something-else/MyBean/local". It has to be declarative rather than with an annotation b/c I can't modify the source of MyBean.java; I only have the jar, which I am packaging into an ear for deployment. 回答1: You can provide this in jboss.xml http://docs.jboss

EJB 3.1 Singleton + JPA + JSF design advice needed

做~自己de王妃 提交于 2019-12-22 06:58:44
问题 Given: simple JSF webapp (no Seam), having JSF beans calling few EJB's which in turn load and persist JPA entities. What I want to is to use @Singleton annotation for ejb's and inject EntityManager instead of EntityManagerFactory : @Singleton public class MyEJB { @PersistenceContext(unitName = PERSISTENCE_UNIT_NAME) protected EntityManager em; // not EntityManagerFactory } Spec says that @Singleton is thread-safe, supports concurrency and transaction attributes which (from my pov) makes it

Configuring MappedName annotation in Message Driven Bean dynamically

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:19:16
问题 When using Message Driven BEans, the destination name from where to receive messages is hard coded in the annotation @MessageDriven(mappedName = "someDestinationName") Is there a way to add this information at runtime? Bellow is a sample Message Driven Bean class. package mdb.beans; import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.jms.Message; import javax.jms.MessageListener; @MessageDriven(mappedName = "someDestinationName", activationConfig = {

What do i get from setting this TransactionAttributeType.NOT_SUPPORTED

对着背影说爱祢 提交于 2019-12-22 04:41:35
问题 I happen to find examples that uses this construct though I am not sure what can I get from this? Does it means that all select statements in a stateless EJB should follow this? @Stateless public class EmployeeFacade { @PersistenceContext(unitName="EmployeeService") EntityManager em; @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<Department> findAllEmployees() { return em.createQuery("SELECT e FROM Employee e", Employee.class) .getResultList(); } What do I get from

How do I access EJB bean when inside a custom Converter [duplicate]

旧街凉风 提交于 2019-12-22 01:31:38
问题 This question already has answers here : How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter? (5 answers) Closed 5 years ago . This converter is called from my JSF. I already register it inside faces-config.xml public class ProjectConverter implements Converter{ @EJB DocumentSBean sBean; @ManagedProperty(value="#{logging}") private Logging log; public ProjectConverter(){ } public Object getAsObject(FacesContext context, UIComponent component, String value) {

Server-initiated Rendering: EJB -> FacesContext?

梦想的初衷 提交于 2019-12-21 21:50:11
问题 I've already asked this question on the Icefaces forum, but meanwhile I realized that this is a more generic problem. I'd like to update parts of a JSF page when I get a message in my MDB. The problem is, how do I get the FacesContext from the EJB container? In the message processing function FacesContext.getCurrentInstance() returns null. I've also tried to make a JSF managed bean be a MDB, but I couldn't (it seems you can't have both in the same class?). Since I'm a beginner in the JSF

Application Client access EJB on Glassfish via a remote interface. Can I do it via local interface?

一曲冷凌霜 提交于 2019-12-21 20:27:47
问题 I recently gone through a Netbeans article about how to create and Enterprise Application Client that access EJB deploy on Glassfish.(Article Link Here) I have couples questions about this article. The article exposes the EJB via a remote interface, I think this will result in application client have to make a remote invocation. There are overheads for doing this. While local interface parameters are passed by reference, remote interface parameters are passed by value, which results in

How to configure embedded OpenEJB container for tests properly?

梦想与她 提交于 2019-12-21 15:24:10
问题 This is my SLSB: @Stateless public class MyService { PersistenceContext(unitName = "abc") EntityManager em; public boolean exists(int id) { return this.em.find(Employee.class, id) != null; } } This is my persistence.xml (I'm using Glassfish v3): <persistence> <persistence-unit name="abc"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/MyDS</jta-data-source> <properties> <property name="hibernate.archive.autodetection" value="class" /> <property name=