Solved

EJB referencing question

Posted on 2004-08-23
6
166 Views
Last Modified: 2013-11-24
can I reference another entity EJB in ejbCreate() method?

for example:
This is what I want to do in my entityA EJB

public int TrackRecord::ejbCreate (int data)
{
   InitialContext ctx = new InitialContext();

   CounterLocalHome home = (CounterLocalHome)ctx.lookup ("ejb/CounterLocalHome");

   counter = home.getPrimaryKey(1);

   this.rowId = counter.increment();
   this.data = data;

   return rowId;
}
0
Comment
Question by:zollen
  • 3
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
ID: 11878617
I don't see why you couldn't.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 11878631
What exactly do you want to do? What's the requirement that drives you to do that?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11878641
Just try it and see if it works.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 30

Expert Comment

by:Mayank S
ID: 11878669
It should work :) but what's the need to do that ;-) ?

I see a small design-flaw here. If this.rowId needs the value which it obtains from home.getPrimaryKey(1).increment.... can't that be done from outside the ejbCreate () method as well? The calling block of code can obtain that value and pass it from somewhere....
0
 
LVL 35

Expert Comment

by:girionis
ID: 11882923
:)
0
 

Author Comment

by:zollen
ID: 11886219
well. u are the first one to answer my question :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now