Adeel Ansari

Ranch Hand
+ Follow
since Aug 15, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Adeel Ansari

@Ankit: I believe, we can use Struts2 with Struts1, as far as we know what are we up to. In fact, I tried it in past. But here, its apparent that mixing both will screw up the things, especially for the beginner and who doesn't know what he/she is doing. Hence, I do agree with you here.
14 years ago

Abimaran Kugathasan wrote:
We don't need to put the post-fix f in the 3rd line. Why is that, What's really happening?



I assume you folks already got the point. Just clear up the things. There in the third line, whether you put a f or not it wouldn't change the type of argument you are passing. That would still be a string. The whole point of passing a f is to make the number float, otherwise a decimal literal is of double type. And there is no method like, Float.valueOf(double), exists.
There are many, IMO. 10 from the top of my head at the time of writing.

- Mr. Smith Goes to Washington (Jean Arthur played awesome. I first time felt that a Hollywood actress can be that good)
- Pulp Fiction (I like the idea of putting sequence in random order)
- God Father 1 (Of course)
- God Father 2 (I like Robert too)
- The Lord of The Rings - all 3 (Brilliant work)
- Being There (Peter Sellers played well)
- V for Vendetta (Remember remember ....)
- Sixth Sense (Love the ending)
- Shutter Island (DiCaprio is really a very good actor)
- Apocalypto

12 Angry Men, I will probably watch this weekend. Yeah, I know its too late.
14 years ago
My guess, you are looping through the HashMap, using its key set, correct? And then you are expecting it to maintain the order, in which those key/values were put. Isn't it?

If yes, then you need to read the docs of java.util.HashMap.
14 years ago
JSP
Try looking at JAXP, that sounds appropriate for your case.
From the syntax ref:

The <jsp:useBean> element locates or instantiates a JavaBeans component. <jsp:useBean> first attempts to locate an instance of the Bean. If the Bean does not exist, <jsp:useBean> instantiates it from a class or serialized template.

Yes, precisely again . You can try that out yourself by giving 0010 as your input.
Cheers.
14 years ago
Precisely, when you enter "10", its interpreted as "0010". Are you getting the point now?
14 years ago
Are you talking about Hibernate? Assuming yes.

Criteria API is a facility given by Hibernate to the folks, who are not comfortable with SQL or doesn't like to write that ;). It has a several methods to prepare an SQL statement. Although, its very powerful and rich, but sometimes you have to go with SQL/HQL way when things are more sophisticated and deem out of reach of Criteria API.

Now Query, here its very ambiguous. Are you talking about HQL, or javax.persistence.Query?
Thanks James, for your input.

I just finished up fixing this. Actually, I noticed the data which existed before I start my Glassfish, doesn't have any issue in loading. But when I persist some fresh entities, and try to load that along with all its eager fetch associations. The associations were being picked up from cache, I believe. Because problem doesn't persist after I restart the Glassfish, and invoke my bean. For fresh entities its always the same, not getting loaded.

Since, my actual query is FOR UPDATE, that really picks all the records from database, but its associations are get loaded from cache if found. So, I tried to use TopLinkQueryHints.REFRESH=true, and TopLinkQueryHints.REFRESH_CASCADE=CascadePolicy.CascadeAllParts. That didn't work, no idea why. It should, IMO.

Now the fix. I manually called `em.referesh()` on that particular entity, which was being picked up from cache. That solved my issue. Below is the modified method,

I think no I didn't find anything. By some reason its not loading OneToOne, and a ManyToOne relationship for one of the object. That I expect it to load eagerly.
I think, I have solved it. Will post the fix tomorrow, hopefully, after testing.
Consider this log.


Now, the first query, stated in the log, is giving me 5 records.


And for some stupid reason its not retrieving anything with the second query in the log when its binding value, `3bdac813d6034a26b336804794fb667f`. I expect one record, of course. For other 4 values I am getting things perfectly fine, just not getting for the first one. I omitted the log for other values, by the way. And yes, its not particularly happens to the first record always. The behaviour is arbitrary sometimes happens, sometimes not, and could happen to any record.

To make it clear explicitly, the first query is `FOR UPDATE`, all others are just loading relations.

Now the code snippet.


In the code, I am trying to load references eagerly. Didn't put the `fetchType=FETCH_TYPE.EAGER` attribute, because don't always want that kinda behaviour. But in this case I need that, so doing it manually.
As a compliment to Jeanne's post. 'carName' doesn't even sound unique. If you just came up with this to show your idea, then its okay arguably. Otherwise, introducing a surrogate key, if there are no candidates found, is a good idea. Folks prefer surrogate keys over natural, but again it depends upon case to case. Surrogate key is the only solution, in case you have no natural candidates.