Solved

EJB referencing question

Posted on 2004-08-23
6
164 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
Comment Utility
I don't see why you couldn't.
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
What exactly do you want to do? What's the requirement that drives you to do that?
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
Just try it and see if it works.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
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
Comment Utility
:)
0
 

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

763 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

10 Experts available now in Live!

Get 1:1 Help Now