Sagar Shroff

Ranch Hand
+ Follow
since Jun 07, 2011
Merit badge: grant badges
Biography
i am a typical cancerian, passionate, impulsive, hot tempered , courageous , impatient, confident (and sometimes over confident), undiplomatic ,and i love my freedom
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sagar Shroff

Hi ranchers, it’s been a while I posted something but now I am back as I am planning to upgrade my oracle Java certification. Long time back I had cleared ocjp6 certification, does it make me eligible to give this exam in question?

I understand that oracle has a separate oracle upgrade certification 817. However, on looking through the objectives of both exams; I am more keen to give 819.

Thanks for your time.

Regards,
Sagar.
Hello Ranchers,

Attached is the image of Nassi-Shneidermann diagram of Groovy’s decision logic for method invocation.
Based on the flow diagram if the the method does not exist it calls GroovyObject.invokeMethod

I have written a scenario where the code does not comply the diagram in case if the method is missing.


Basically I have extended MetaClassImpl to capture all the MetaClass.invokeMethod calls. And also implemented invokeMethod in my object 'MyMarkupBuilder' to capture calls to GroovyObject.invokeMethod
I change the metaClass to my implementation and invocation goes to metaClass.invokeMethod instead of object.inokeMethod.

Definitely the diagram does further decision making which i am not aware of. If anyone can throw some light on this subject it will highly appreciated.

Regards,
Shroff.
9 years ago
Hello ranchers,

I was reading Gina(Groovy in Action) and its Section 3.1 clearly states that in Groovy World everything is 'Object' and replaces corresponding wrappers wherever required.
I tried a small example as follows:

On decompiling found that in line1 groovy replaces new Integer(1) but for line2 it declares int variable (rather then Integer reference type).
Any of the rancher wants to throw some light on this ?


Regards,
Shroff.
10 years ago
That sounds correct. Thanks Jeanne.
10 years ago
I was amazed the way groovy's Trait allows us to extend behavior of any object.

For example:

Output: Parent: Hello Groovy

HelloChild is a final class ,I want to understand the way groovy implements this feature. According to my understanding when groovy deals with 'as' clause
it creates a proxy which extends the instance class (HelloChild) & implements the Trait. But since HelloChild is a final class i am not sure of how it works.
May be through some byte code instrumentation ? Not sure. Would be great if any ranchers knows of the internals and share their knowledge.

Regards,
Shroff.
10 years ago

Rob Spoor wrote:How about a bean annotated with @Singleton and @Startup? You still don't have full control over the startup order if you use other mechanisms (like ServletContextListener), but at least you can use @DependsOn to specify that these beans should be loaded after another.



Thanks. Actually i was trying to figure out whether there is any way i can achieve to put all my initialization code in ear project. But then reading through articles i realized that ear core objective is packaging of application.


Regards,
Shroff.

Jaikiran Pai wrote:
You can use initialize-in-order within the application.xml and then list the war modules in the right order and have the initialization done in the first listed war.


Yeah thats what i am backing on currently, just wanted to know if this is the only standard way ?


Regards,
Shroff.
Hello ranchers,
I am facing an issue in my design of my application and struggling to get a robust solution for it.
To lay it down in simple terms i have an EAR which has currently 1 war and 1 ejb jar. I am expecting my EAR to scale up in near time,
where i will be having few more wars and business components added. Currently i am using a ServletContextListener to do all the application level initialization.
But then later noticed that it is not a correct solution as i don't want to depend on sequence of servlet's startups (from different wars).
There should be some standardized solution which allows me to do initialization at application level. In simple terms i want to execute some piece of code(at EAR level)
before any other code gets executed.


Regards,
Shroff.
Hello , have a query regarding SessionImpl.getEntityName(EntityObject) , why does hibernate allows to retrieve entity name only for persistent entities and why not for transient
entities ? when i try to invoke getEntityName(object) before invoking persist() it throws TransientObjectException. Any logical reason for doing this ?

Regards,
Shroff.
Hello all ranchers , as i was reading Java Persistence with Hibernate in Chapter : Hibernate Type System , i came across topic which was discussing entity and value types.
The topic mentioned that navigation from value type to entity type is possible but vice-versa is not possible. I took an example of a User(EntityType) and Address(ValueType),
so a User entity has an Address. So according to this example i can in fact navigate from a user to its address which conflict with the above statement. Can someone please help me
in understanding this topic by giving me a small example ? Will be really appreciated.

Regards,
Shroff.
I just found the solution to my typical scenario i should replace persist with merge in the function.
I am new to Jpa-Hibernate , so as i am learning i also want to consider the performance implications.
So i will still like to know/hear from ull if any better or appropriate solution with respect to Performance.

Thanks,
Shroff.
Hi ,
I am using Jpa-Hibernate , I want to know if there is any effective way of checking whether the entity exist in the database before persisting it actually to the database.
Let me explain my question with the following example
I have created a function which takes object as an argument and does persisting for you with all the boilerplate code of creating transaction , closing session.


1. Create a Person entity
2. Persist the person entity using the above function.
3. Now if someone by mistakenly again calls the above function with the same entity which has been already persisted , then i will get


So i wanted to know whether there is an effective way (in terms of performance ) of checking whether the entity exist in the database and then do a persist.
Something like the following


I dont want to query the database for that check , some solution through which i can do a check in memory area which Hibernate uses.

Regards,
Shroff.
Will be really helpful to me if someone can help me understand why my advice method is not getting called.

Regards,
Shroff.
Hi ranchers ,
I am trying a small example of After advice. I am having following class


I have following spring configuration :


And when i invoke hello() , the after advice method i.e bye() does not get invoked. Can someone please help me where exactly have i made mistake as this is very basic and as i have just started with spring.

Regards,
Shroff.
Thanks a lot for your detail explanation....Showing the different possible ways definitely helped

Regards,
Shroff.