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 ...
Hi,
I have an EJB deployed on my GlassFish v2.1 application server. I have also set up a lifecycle module within GlassFish which utilises this bean when it receives a READY_EVENT type. I have the following code to look up the bean:
BusinessInterface bean = (BusinessInterface) initialContext.lookup("JNDI lookup name");
...
// do somet...
I have a collection of states, that I want to cache for the life of the application, preferably after it is called for the first time. I'm using EclipseLink as my persistence provider. In my EJB3 entity I have the following code:
@Cache
@NamedQueries({
@NamedQuery(
name = "State.findAll",
query = "SELECT s FROM State...
I'd like to store username that has last modified table row to as a field in every table.
I have following setup: an user logs in, web layer calls some EJB 3.0 beans. Those EJB beans create and modify some JPA entities.
Now, I'd like that username (from weblayer) would be automatically stored to every JPA entity (and database row) that...
Is it possible to set the database isolation level (ie Serializable, repeatable-read etc) for a given EJB 3 method call?
I understand that this is not covered by the EJB Spec, so details of how to do it on either a JBoss or Glassfish specific manner would be great.
I'm starting to get the impression it's not possible and that you can o...
Is it possible to use hibernate as Glassfish's persistence provider and if so HOW?
...
We all know that in the web tier there is the possibility that only a single instance of a given Servlet exists which services multiple requests. This can lead to threading issues in instance variables.
My question is, is it safe to inject an EJB using the @EJB annotation into a servlet as an instance variable?
My initial instinct woul...
It was my understanding that JBossAS 5.x supported EJB3 bean injection in servlets with the @EJB3 annotation. I'm using the default configuration for JBossAS 5.0.1.GA and it's not working. I've added the mappedName argument to the @EJB annotation with the session beans JNDI name, and it just doesn't do anything. No apparent errors, the b...
Hey! I'm relative new to both Java EE and Stackowerflow, please be kind :-)
I have a bunch of devices triggering Java messages to be sent on any state change. These devices are typically active for about 30-90 minute intervals. Each event message contains a device id in addition to the event details.
Central in my application is a me...
Is it possible to "self inject" an EJB in order to call local methods as bean methods? There are some cases where this could be favorable, for example if container managed transactions are used and something should be accomplished in a new transaction.
An example how this could work:
Foo.java:
@Local
public interface FoO {
public ...
Say I have the following EJB (using ejb3):
@Stateless(name="Queries")
@Remote(Queries.class)
@Local(Queries.class)
public final class QueriesEJB implements Queries {
...
}
The class is available through both a local and a remote interface.
How can I inject the local interface for this EJB in another part of the app?
Specifically...
Lately I decided to implement in my project CMT transactions (jBoss5, Hibernate, jta postgres datasource).
Everything is working fine except Hibernate.initialize() in my entities.
It works in EJB beans but when trying to invoke initialize in entity getter I get "couldn't associate with session" exception. It worked just fine before imple...
I have Enterprise Application with EJB3 and JSF on Glassfish server. After running this application for more than 2 weeks I realized that I have problem with Class Loading. I don't think this is a problem with permgen. The classes loaded every time when I open a page but then they never erased from the memory. Here is the snapshot of or ...
Is it possible to have objects stored in a data structure for the duration of an App Server's uptime? Basically I want an EJB that interfaces with this Data Structure, but does not require a full fledged database solution.
As an example I made this dummy animal object:
package com.test.entities;
public class Animal implements java.io...
I need a method to be called in an App Server (Glassfish) every 5 seconds, no matter what. Are timers reliable enough for this? What are my options.
...
I am currently working on some older java code that was developed without App Servers in mind. It is basically a bunch of "black box code" with an input interface, and an output interface. Everything in the "black box" classes are static Data Structures that contain state, which are put through algorithms at timed intervals (every 10 s...
Is there a noticeable amount of performance overhead in using Remote Bean Interface over using a Local Bean Interface? I would like to have every Client application connect to remote beans if there is little performance difference.
...
I have a stateless bean resposible for persisting entities to a database. This stateless bean is called by a message bean's onMessage method. The wired thing is that on the first message everything works fine, but on the next message the method responsible for persisting is invoked outside a transaction, even though the method is annotat...
I would need to implement an audit log for a web application written with JBoss Seam. EntityListeners seem like good candidates, but I don't know how to connect the EntityListeners to the application session context to include the logged in used principal in the audit record.
I wonder if there is a way to do this "connection", or if the...
Is there something I can call from a POJO to see if the code is currently in an App Server or outside of an App Server?
Something like this (In rough PseudoCode):
System.getRunningEnvironment().equals(Environment.Glassfish)
or
System.getRunningEnvironment().equals(Environment.ApplicationServer)
or
System.getRunningEnvironment().e...