Schandha Ravi

Ranch Hand
+ Follow
since Oct 20, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Schandha Ravi

Thank you Ralph... I have not studied much on EJBs and espicially after EJB 2.0. It seems I'm far behind in race :-). Got to get some hands on with latest versions.
Thanks for the reply. I have couple of more questions around this topic.


Schandha Ravi wrote:
Can I synchronize the code using block synchronization in session bean, where the entity beans are persisted around the primary key generation and persistance of the entity bean.

No, an ejb must not use thread synchronization (except it's an EJB3.1-singleton bean with bean-managed concurrency).



Why the thread synchronization not permitted in an ejb. I'm sure it would not throw me any compiler errors. But what potential problems could we face, if used. Would this intervene with container and result into undesirable situation. What changes came in for allowing this in EJB3.1

Coming to my question posted earlier, I'm thinking of another approach for gaining the control of primary key. Since, all I needed was to send back the right primary key to the calling application, can't I try retrieving it in ejbPostCreate(). Would that be inviting the trouble ?
Hello All,

In our project, the existing design is as follows :

1) When an Entity bean is created, we are assigning the primary key of that entity as "0" like,

someHome.create(0,........);
2) But there is a database trigger defined, which would assign a primary key for NEW or UPDATE operation.

This design worked fine, because the calling application is not bothered about primary key.


Now we have a production problem, where in we need to act upon the primary key. We could easily fix this, by generating the primary key upfront and assign it instead having the trigger generate it for us. But this will impact so many other interfaces. One more thing, which is very important here to understand is, the trigger takes the primary key of the latest entity persisted and increments by 1 to generate the next primary key. I was proposing to query the table to determine the latest primary key and increment it just like trigger doing and use that new primary key to persist the next entity. But there was a question concerning the following of ACID properties here. How can we ensure that before a new key is identified and assigned, there was not another request for peristing another entity and we mix up the keys. I'm not sure about the issues I can get into with this, but some how that proposal was denied.

Can I synchronize the code using block synchronization in session bean, where the entity beans are persisted around the primary key generation and persistance of the entity bean.

Some thing like


Any suggestions here.

Thanks
Ravi CKota
Ramakrishna,

Here is my understanding. You can weigh on this.

When you navigated from Page1 to Page2, you are adding the item to the statefull session bean and moving ahead to page 2. Now when you are navigating from page 2 to page 3, are you sure that you are actually calling the same sessionbean. Even though you are using statefull session bean, the next request is a new request altogether and container will assign the new bean. So, by the time you go to the last page, you get results from the last session bean created. Simply to put, I think it is not one single session you are dealing with. I may be completely wrong here. Can you put some debug statements and see if you are actually dealing with only one bean.
Hi,

Nobody calls enterprise beans directly, except containers. We have the interfaces to access the EJBs and we use Remote and Local interfaces for this. Below is the sequence of events.

1) Getting reference to home interface, typically using JNDI.
2) Call create method on home interface, that would result you the remote interface of the EJB.
3) Now you have the required interface and you can invoke the business methods on that interface.

This is what I know, from the earlier versions of EJB specs. But not sure if this holds good for EJB 3.0 and later. You may want to check the specs.
Thank you Vijitha Kumara.
9 years ago
Is this not something related to asynchronous communication ? If so, can't we use JMS messaging model. Is there any constraint that it needs to be a web application. I'm having questions on the reliability of using a web application here. Once the servlet sends the request to an external process opening a socket (which may be external to the web application context) how do we maintain the session.

This seem to be a very interesting usecase and I would be glad to learn the solution if anyone has.
9 years ago
Please see the below code,

I have two classes Person and Student, such a way that Student extends Person.

Person class


Student class


and my configuration file is as follows


and now through my client, I'm expecting to instantiate Student bean through IoC and need to display the id, name and class. But unfortunately, I'm able to display only the class name.




From the output, I observe that the constructor of Person is invoked when IoC instantiates Student as expected. But when I try displaying the ID and Name, they are displayed as null. Doesn't Spring container assign the values for parent object, before setting them to child object.

9 years ago
Thanks Tim.

It seems there is no ready made solution available for my problem.
9 years ago
Hi All,

In our project we are using Commons HttpClient API to connect to a HTTP site, navigate through each of the pages and submitting forms and we were successful to some extent in navigating to few pages, where ACTION url is a straight hard coded value (from view source). But at some point, we got stuck as the ACTION url is determined by a javascript using some parameters. I wonder, if it is possible to invoke the javascript which is residing on the remote site library, by passing on the parameters "mimicing" the browser and thus obtain the URL. Am I too ambituous and ambiguous ?
9 years ago
Thank you for explaining with an example. I have started reading "Spring in action" to understand more on this framework and I'm sure that I would come up with more questions to ask.
Hi All,

I'm relatively new to Spring and espicially to IoC. Unrelated to Spring, can some one explain me with an example, how IoC is useful over conventional object instantiation (using new keyword). What is the benefit of this re-direction, where in creation and wiring of the objects is delegated to IoC container instead of handling it in code. I'm pretty sure that, there might be something apart from freeing the code from object creation, which does not seem to be lot of problematic.
I love this forum........ May this forum be blessed.
9 years ago
Could any one look into this post and guide me? Let me know, if the information provided is vague or incomplete, so that I can try to furnish more.
Hi All,


As you know in SQL, if a sequence say "seq_one" is defined in a table say "table_one", we can use SELECT SEQ_ONE.NEXTVAL FROM DUAL. We have a system where in currently an Entity bean is used to persist a record (all fields) except primary key in the table. Primary key is handled as a sequence and a trigger is fired for every new record inserted, which would assign NEXTVAL of the primary key. We have a requirement to have it done through the entity bean just like other fields. But the problem is, we still want to use the sequence (primary key is defined as sequence) to determine the next value and assign it as the primary key while creating the Entitybean. I wonder, if this can be achieved using Home Business method, with the help of EJB QL. If so, what should be the EJB QL look like. I tried googling it, but could not find any good information.

If this is not possible, the other option left out with me is to use straight JDBC call.