Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!

Sreenath Madasu

Ranch Hand
+ Follow
since Mar 26, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sreenath Madasu

Hi all!
I have a question regarding URl and URL COnnection. What is the fifference between URLConnection.getInputStream and URL.openStream? They should be the same right? In our application we are opening a URLCOnnection from a URL object to get contenttype, length etc. Then using the same URLObject we are opening stream with openstream and writing out to another stream. Sometimes the length returned by URLConnection is different from the total bytes read from URL.openStream() method. Why is that?

Here are the steps again
1) Create URL Object -- say URLObj1

2) Create URLCOnnection --- URLCon1

3) get contentlength from URLCon1 -- contentLength1

4) OpenStream from URLObj1 as UrlObj1.openStream()

5) Write the above to another stream and count the total bytes read. -- totbytes

6) Sometimes totbytes is different from contentLength1
Why?

Thanks
Sreenath
14 years ago
Hi all!
What is the logic behind catching specific Exception like "SQLException" Vs catching "Exception" as a whole?

Thanks
Sreenath
14 years ago
You could try

select code, count(code) from table
group by code
Finally! you got my point! I am so relieved !!!

apologies duly accepted. Lets forget enimity and

Also that was a nice link you gave there.

Thanks
The following is the excerpt from Final Release of J2EE specs by Sun Microsystems, Inc. I have made the home methods part bold. Mind you this is not my own writing.

10.6.10 Entity bean�s remote home interface

The following are the requirements for the entity bean�s home interface:
The interface must extend the javax.ejb.EJBHome interface.
The methods defined in this interface must follow the rules for RMI-IIOP. This means that their argument and return types must be of valid types for RMI-IIOP, and their throws clauses must include the
java.rmi.RemoteException.
The remote home interface is allowed to have superinterfaces. Use of interface inheritance is subject to
the RMI-IIOP rules for the definition of remote interfaces.
Each method defined in the remote home interface must be one of the following:
� A create method.
� A finder method.
A home method.
Each create method must be named �create<METHOD>�, e.g. createLargeAccounts. Each
create method name must match one of the ejbCreate<METHOD> methods defined in the enterprise
bean class. The matching ejbCreate<METHOD> method must have the same number and types of its
arguments. (Note that the return type is different.)
The return type for a create<METHOD> method must be the entity bean�s remote interface type.
All the exceptions defined in the throws clause of the matching ejbCreate<METHOD> and ejb-
PostCreate<METHOD> methods of the enterprise Bean class must be included in the throws clause
of the matching create method of the home interface (i.e., the set of exceptions defined for the create
method must be a superset of the union of exceptions defined for the ejbCreate<METHOD> and
ejbPostCreate<METHOD> methods).
The throws clause of a create<METHOD> method must include the javax.ejb.CreateException.
Each finder method must be named �find<METHOD>� (e.g. findLargeAccounts).
The return type for a find<METHOD> method must be the entity bean�s remote interface type (for a
single-object finder), or a collection thereof (for a multi-object finder).
The remote home interface must always include the findByPrimaryKey method, which is always a
single-object finder. The method must declare the primary key class as the method argument.
The throws clause of a finder method must include the javax.ejb.FinderException.
Home methods can have arbitrary names, but they must not start with �create�, �find�, or
�remove�. Their argument and return types must be of valid types for RMI-IIOP, and their throws
clauses must include the java.rmi.RemoteException. The matching ejbHome method speci-
fied in the entity bean class must have the same number and types of arguments and must return the
same type as the home method as specified in the remote home interface of the bean.

The remote home interface methods must not expose local interface types, local home interface types,
or the managed collection classes that are used for entity beans with container-managed persistence as
arguments or results.

Even after reading this if you are saying that I am talking nonsense, well! all I can say is "Only ignorant persons say others are ignorant".
Moreover I just don't feel the need to give you sample code(which I have written and tried successfully), I don't see a person willing to learn but just to fight.

Also moderator, could you please close this topic, :roll: I posted this in SCBCD forum and got a better answer from people, who understood the problem in one posting!!!
Also Mr. Valentin!!
Buy yourself "Head First EJB" and read it 4 to 5 times. Then I hope you will understand the problem(before saying it as nonsense!!)
Mr. Valentin!!
You need brush up your EJB2.0 knowledge. Please look into the specs and learn that you can define business methods in the home interface of entity beans. Please think before you say problem is nonsense!
Thanks Keerthi!
That was a nice answer to my problem. But even if you use Iterator pattern, again the dilemma comes whether to use home business methods or finders. I can use the pattern to get as many remote ref(finder way) as needed. But still I have to call remote business methods on them. But if I use the same iterator pattern for home business methods(using ofcourse value objects!), the number of remote calls will reduce. Don't you think so?
Entity Bean home interface can have creaters, finders and home business methods.

1) creater or rather create methods are used to create a row in the database.

My point comes below.

2) finder methods : Client uses finder methods to get a collection of( or one remote ref if it is find by primary key) of the remote references. To get to the data he wants, he iterates through the collection and calls business methods of the remote interfaces. This can be network heavy. If we have 5000 remote interfaces in the collection, it will be atleast so many number of remote calls!!!

3) home business methods : Client uses these methods to get to data directly. This happens only once. Compare 5000 remote calls to one!!

Now the question is when to choose between entity home finders and entity home business methods. If the home business methods returning a collection of data are reducing the network traffic, why do you want to use finders, except for findbyprimarykey?

I POSTED THIS ON EJB FORUM. BUT COULD NOT GET A SATISFACTORY REPLY. SO I AM POSTING IT AGAIN HERE.

Hope you guys understand my problem!!!

Thanks
I am talking about HOME business methods!!!(whether CMP or BMP)

I think I will have to give you an example.

consider an entity in the database like person which has firstname, lastname, sex etc... I will create a domain object "Person" with all the setters and getters etc.

I want to get all the males in the database.

1) First solution is to have a findbySex method in the home interface.
This returns a collection of the remote interfaces satisfying that condition. Then the getters say getFirstName, getLastName etc are called on the remote interface. All these calls are remote.

2) Second solution is to have a HOME business method say getPersonsBySex. This will return a collection of Person objects. Now the client can call getters on these any number of times, and these will not be remote.(Although the data is stale. But stale data is better than network overhead!)

I stress again the difference is in HOME business methods and HOME finders methods!!!
OK!
let me make myself more clear this time. I think there is something wrong with my communication skills

Entity Bean home interface can have creaters, finders and home business methods.

1) creater or rather create methods are used to create a row in the database.

My point comes below.

2) finder methods : Client uses finder methods to get a collection of( or one remote ref if it is find by primary key) of the remote references. To get to the data he wants, he iterates through the collection and calls business methods of the remote interfaces. This can be network heavy. If we have 5000 remote interfaces in the collection, it will be atleast so many number of remote calls!!!

3) home business methods : Client uses these methods to get to data directly. This happens only once. Compare 5000 remote calls to one!!

Now the question is when to choose between entity home finders and entity home business methods. If the home business methods returning a collection of data are reducing the network traffic, why do you want to use finders, except for findbyprimarykey?

Thanks
Hi Valentin!
I am sorry you misinterpreted my question. I was not talking about local or remote interfaces. I was talking about choosing between home business methods and home finders, which can be there both on remote and local home interfaces.
Hi friends!
While designing the home interface how do you choose between home business methods and home finder methods. I know the later retrieves the remote references and client will have to do remote calls to get the data, which will have network overhead. Some say that just to give the data to the client we can use home business methods to return objects other than remote references. Then what is the use of home finders?
Hi All!
I want to write a CMP bean. But the underlying persistnat store has a column DELETE_INDICATOR. I don't want to delete the row from the database when I say ejbRemove but to set it to 'Y'. As I understand CMP writes JDBC logic to delete it from database . What is the work around?

Thanks
Sreenath