Arun Singh Raaj

Ranch Hand
+ Follow
since Jan 30, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
106
Given in last 30 days
8
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Arun Singh Raaj

Can anyone please explain "Reference to an instance method of an arbitrary object of a particular type" in Method Reference Java 8?
Why in general method isn't allowed with Employee reference:
But it is valid when you:
I could not understand by the explanation written in java docs, it would be great if anyone could help.
Thanks in advance.
1 week ago
Why does Java not allow dynamic binding for static methods?
Thanks.
1 week ago
Thanks for replying.

Does @Transient annotation exclude the specific field while sending the JSON data? or it's specific to only Serialization? Does @Transient work in non-'Serializable' class?
1 week ago
I downloaded some Java web projects and noticed that their POJO classes inherit Serializable interface. I know that Serializable interface performs serialization as it converts the Java objects into bytestream but my doubt is, if you are using Web-services then Java objects are going to be converted into JSON data and sent to the client. Then why do you need Serialization in a webapp?

Thanks in advance.
1 week ago
If there are 15 items in this List and 5 of them already exist in the db so only 10 are going to be stored into db, while I've used @ControllerAdvice so all the Exceptions go there, but after this operation how to track which 5 items weren't saved successfully and how to let user know about those 5 items?

Will the iteration keep going until the last element of the List despite Exceptions occur 5 times?

Thanks.
2 weeks ago
If you have to insert the records with batch processing, do you use @Transactional at service layer?
Is it DAO class where you write batch processing logic or the service class?


Thanks in advance.
3 weeks ago
Alright I get it. Thanks for the detailed answer Mike!
Thank you all.
3 weeks ago
Have to know its internal working, it's being asked in interviews. It would be nice if you could help.

My doubt is, assume you have "hello" key which is stored at index 5. Now after many insertions, the bucket size is increased, so obviously the result of index formula will also vary even for the same keys.
So when I try to retrieve the value using
get("hello");
How will it calculate the same index when bucket size is not the same anymore?

Thanks.
3 weeks ago
True!
So in case I try to store duplicate key, does it firstly calculate the index then check the particular index of bucket or
it firstly compares all the keys of all the buckets with the one you are going to store?
3 weeks ago

If the key is a String instance = "hello". If hash of "hello" is 99162322 so initially when bucket size is 16, Java calculates the index:
(99162322 & 15) = 2     and the entryset gets stored into index 2.

But how does it get the same index for another "hello" when bucket size is 32 or more?
Or my understanding is wrong, it's not mandatory to have the same index for two same instances?

Thanks in advance.
3 weeks ago

Stephan van Hulst wrote:And if two users try to reserve a seat at the same time, it can be solved by performing the reservation (making a change in the database) in a database transaction. If the transaction fails because a seat was already reserved, the user can be notified of this.


Hi, what makes the transaction fail in this case? try to overwrite the PK in db? (But the PK will be different for every transaction when PK is auto-generated.)
How does Hibernate make sure the specific seat already exist in db? (If you say you run a query that checks if the specific seat# with the specific date already exist then still concurrent access of multiple threads may pass this condition.)
Thanks.
When only one user out of all concurrent users does book a particular seat and the booking happens after the payment is made. Then what happens to the payment of remaining users who were discarded to book because one has already occupied the seat. How does the payment get reverted?
Thanks.
I've been searching for the solution for an hour but couldn't make it. The docs link you provided tells which strategy not to use but not which one to use. I assume it tells you can use all except the IDENTITY.
I find only three types of PK generators to use with annotations that are IDENTITY, SEQUENCE AND TABLE.
I found about custom-generator too where you have to implement IdentifierGenerator interface but the example I saw executes the query to fetch the total count from db means it still depends on db on every insertions. I'm confused.
I don't tell anyone here to write the code but to atleast provide the name of the strategy that fits batch processing and a link that explains it.
Thanks.
If there's a ticket booking app, since every user comes with a new thread, there are chances multiple users do click on the same "seat" at the same time and proceed to book. There are chances the final payment submission also may happen concurrently. How to avoid race condition in this case?

Thanks in advance.