Caine Lai

Greenhorn
+ Follow
since Sep 21, 2005
Merit badge: grant badges
For More
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 Caine Lai

Thanks for the response. Yes, the id is indexed but apparently "max" still performs a full scan on MySQL. I am familiar with the SQL JOIN, yes. But I'm not sure how to do this in JPA.

In SQL I would do:



But I'm not sure how to write this in JPA.
I would be very grateful if someone were to help me with this JPA query. The object structure is simple. I have sessions and I have tasks. I would like to find the latest Task for a given Session.

So far, I have been able to do it with this query:



The problem is that if a session has many tasks (say 30,000 or so) than the query takes a VERY long time to process (30-60 seconds). I would like to optimize the sub-query to get rid of the max statement since that is what is expensive.

I would LIKE to do:



But I guess you cannot do a LIMIT clause in a sub-query. Can anyone think of a more performant solution to my problem?

Thanks!
So to get around this issue I have resorted to having to do this:


Please tell me there is a better way...?

Thanks.
Maybe someone has an idea how to do this. I want to collect some statistics using JPA and return them all as a value object to my web tier.

In my value object I have a static inner class I would like to use for the JPA query. Is this possible?

My Class:


And here is the method I am trying to execute:


The error:
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [vo.stats.vendor.GeneralVendorStatsVO.StatusCounts]

I don't know why this would not work, when I can do:


Any ideas? Thanks!
Ooooo... yeah that's what I want. Thanks a lot.
18 years ago
Such as:

[ December 22, 2005: Message edited by: Caine Lai ]
18 years ago
Could someone please help me with creating a regex that will validate user input for a name field?

This is what I have so far. See anything missing? The special characters listed are for matching common european characters used in names. I'm not too worried about complete localized names unless there is a simple way to do this.

Current Regex Pattern: ^([A-Za-z�-��-��-� '`\\.,])+

Thanks!
18 years ago
Thanks for the info!
18 years ago
The reason this came up is because we are using a mini-framework for our application since it is a small app with only about a dozen or so pages. By small I mean small in number of pages. But will need to scale to hundreds if not thousands of concurrent users.

We have a controller servlet that extends HttpServlet. The controller servlet handles all security authentication and initialization of data used in every page. Such as header data, etc.

And then we have one separate servlet for each .jsp view that handles the data processing for the view. Each of these servlets extends the controller servlet to handle the page specific data before forwarding it to the view.

So from an architectural standpoint do you think this sounds like it will scale adequately?
[ November 23, 2005: Message edited by: Than Long ]
18 years ago
<form name="myForm" id="myForm" method="post" action="/myNextActionServlet">
<input type="hidden" name="firstName" id="firstName" value="${ first }" />
<input type="submit" name="submit" id="submit" value="Next Step ->" />
</form>

In your servlet you would then get the value with

String firstName = request.getParameter("firstName");
[ November 23, 2005: Message edited by: Than Long ]
18 years ago
Hi, I was wondering if there is a big performance overhead with storing objects in the request. One way we would like to keep Java code out of our JSP's is to process all our Java code in a servlet and set the java objects into request scope to be used by the JSP. And then forwarding the request to the JSP for presentation.

Anyone see anything wrong with this from a scalability standpoint?
18 years ago
No offense, but writing to a file is a horrible idea. Why don't you just implement a checking mechanism in the servlet context object that makes sure you get the correct data for the sessions you are trying to share data between? It doesn't necessarily have to be available to everyone. Just make sure your code does the necessary checks before handing the data out.
18 years ago
An HTML option box has no state. There is no way for it to know which option should be selected. When you reload that page, it is simply outputting the HTML that was originally there.

You must pass an attribute to the JSP page from the servlet that will indicate which value should be selected in the option box.

// A quick and dirty example.
// Servlet that handles your JSP request.
String optionSelected = request.getParameter("myOptionBox");
request.setAttribute("optionSelected", optionSelected);

// A quick and dirty example.
// JSP code that selects the correct option in the option box.
<select name="myOptionBox">
<c:forEach items="${ optionData }" var="option">
<option value="${ option }" <c:if test="${ option == optionSelected }">selected</c:if>>${ option }</option>
</c:forEach>
</select>

Hope this helps. You might check java.sun.com for some JSP and Servlet tutorials.
18 years ago

Originally posted by Adeel Ansari:
Well, if some request take a lot of time in processing then the server suppose that the thread hung somewhere during process and then server kills that thread. However, if you respond back time by time while having your other thread scaning files, it would be ok.



Why don't you launch a background thread when Tomcat starts, with a context listener? This way you don't have to worry about the thread timing out. You could have this background thread (or threads) do their processing and store information into the application scope that the JSP threads can access to get the information they need.
18 years ago