Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Santosh Manikandan

Greenhorn
+ Follow
since Sep 11, 2011
Santosh likes ...
C++ Java
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 Santosh Manikandan

1. A software service can be defined as a system meant to interoperate with other software systems (console,gui,server-based,middleware etc) probably written in some other language.
2. Servlets were never meant to provide "services". They are just Java classes which can participate in a request-response cycle under the HTTP protocol.
3. Servlets need a JavaEE compliant server to be hosted. Web services have no such requirements.
4. Servlets map a URI to a Java class which has a well-defined lifecycle (instantiation-init-service-do*-destroy). This gets further complicated with the addition of filters. Web services map a URI to a method/function which has a much simpler lifecycle.
5. Servlets can keep track of a web application's state and control its workflow. RESTful services are generally stateless and a simpler workflow.


Hope this helps
5 years ago


Hey people, I need to map the the common attributes inherited from Address in the Contact class to request parameters with JAX-RS. How can I do this ? I am using Jersey 1.18 and a.f.a.i.k there are some JAX-RS implementations which support the addition of a "prefix" to request parameters. Any help is much appreciated. Thanks in advance.
5 years ago


will return a fully loaded object of the User entity with userId = 1 if found. it returns null otherwise



will return a proxy User object with the identifier property populated without hitting the database. It hits the DB only when you attempt to access a non-identifier property and it is then that it throws an exception if a record with userId = 1 is not found. Does not throw an exception while you are accessing the identifier property only.

Now, given a scenario where in a e-commerce system User is creating a Bid. Bid has a one-to-one association with User. When a Bid object is created, its user attribute needs to be populated with a User object. When the Bid object is subsequently saved in the Bid table the foreign key reference to User table needs to be set. Given this, you may want to ask yourself ; do you really want a fully loaded User object in Bid just for setting the value of a foreign key in Bid table OR is it more than sufficient to achieve the same thing with a proxy.

I bet you have written instead of
Ok people, after much digging this is what I can conclude. Just wanted to share my spoils with you all. If anyone feels they can add more to this, you are most welcome. Let me start with a sample data set.



Q2. With session.get() when lazy=true, fetch=subselect why does not Hibernate execute a subselect ? I guess this is because it is absolutely un-necessary. Am I correct ?
A2. Yes a subselect is absolutely un-necessary here. Here is what the subselect might look like


I do not see any benefit of executing a sub-select here over the current strategy of simply executing a seperate select for contact records. Infact, a subselect might be an un-necessary performance drain.

Q3. With session.get() when lazy=false, fetch=subselect why does not Hibernate execute a subselect ? It should execute one here but it does not. I wonder why ?
A3. Ok. Again here is what the sub-select might look like (exactly similar to the one above with some other id)


As you can see this will not yield any records since USER_ID=3 does not have any contact records. That defeats the whole purpose of doing session.get() for a User record wherein get() will return null inspite of having a valid User record in the table. So again, a seperate select for contact records is the only way out.

Q4. With session.createQuery() when lazy=true, fetch=join why does Hibernate lazy load ? It did not do this earlier with session.get()
Q5. With session.createQuery() when lazy=false, fetch=join why does not Hibernate use a join ?
Ans. My current understanding says that this maybe simply because Hibernate does not want to end up firing a join which selects a huge data set (comprising all User records and their Contact records) and loading a huge collection in-memory.


Hey People. No responses yet. Kindly let me know if something is unclear. Thanks.
ok, here you go

Step 1 : Browser sends the first request
Step 2 : Web container receives the request.
Step 3 : Web application processes the request, creates a new HttpSession object and stores something in a HttpSession object
Step 4 : Web application writes to the response and commits
Step 5 : Web container writes a session cookie containing the session-id to the response header
Step 6 : Response sent to the client
Step 7 : Browser receives the response
Step 8 : Browser rejects the cookie because cookies are disabled
Step 9 : Browser sends second request but this request does not transmit the cookie information since the cookie was rejected
Step 10: Web container receives the request
Step 11: Web application processes the request, tries to look for a session-id but does not find it, hence assumes it is a new request. Now if a HttpSession is needed again, you will get a new HttpSession object. What about the original and information stored earlier in it ? Well, that is gone.

So, in such a scenario if the session-id needs to be reliably transmitted between a server and client and back to the server so that a server-side HttpSession can be reliably used, how can you do that ?
URL Rewriting
7 years ago
I am using Hibernate 3.6
User is an entity class
Contact is an entity class
User has a Set<Contact>
The relationship is uni-directional and mapped as one-to-many.

I have tried out the following lazy loading and fetch combinations. Here is a list of my understanding and actual results.



Here are a few questions I have:
1. Is my understanding correct ?
2. With session.get() when lazy=true, fetch=subselect why does not Hibernate execute a subselect ? I guess this is because it is absolutely un-necessary. Am I correct ?
3. With session.get() when lazy=false, fetch=subselect why does not Hibernate execute a subselect ? It should execute one here but it does not. I wonder why ?
4. With session.createQuery() when lazy=true, fetch=join why does Hibernate lazy load ? It did not do this earlier with session.get()
5. With session.createQuery() when lazy=false, fetch=join why does not Hibernate use a join ?

Thanks in advance