jay desi

Greenhorn
+ Follow
since Jul 02, 2009
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 jay desi

I tried to create an entity class from database in netbeans using hibernate. However, one of the db table
does not have a primary key, but an index. And it didnt allow me to create an entity class frm that table.
So, I guess we cannot use hibernate to map table to object if we dont have any primary key. Am
I correct?
thanks cameron...Oh and going through some tutorials mentioned in your signature..They seem to be very good.
david...thanks for a quick reply..
I cannot modify schema because I am not allowed to do so...its a very old db schema..
all,

I am a hibernate newbie.

I work with an older mysql database. This schema does not have foreign-key constraints between various
tables syntactically. Although, conceptually speaking, there are many foreign-key relationships between these tables.

Eg:- This is a sample table :-







The second table ideally should have been:-




However, I cannot modify schema now.My question is that Can I still use Hibernate annotations here.
Can I still use @OneToMany if there are no foreign key constraints on database tables?
Thanks Gerardo...

My webapp does not allow inserts or updates...The db inserts/updates take place at a different facility which is completely independent
of this webapp and I cannot modify anything inside db schema....So when you said:-


What you can do is check after an insert/update is done and verify if an update needs to be done
...
This thread wakes up on every insert and does the job while the insert process is freed to continue accepting inserts.



you meant writing some kind of database triggers, which I am not allowed to modify. I dont see any other way in which insert or update in db can trigger a thread.

Your approach has proved a good learning experience for me.
14 years ago
thanks Gerardo..This is a very efficient approach..However, I feel wrt my app, I might face some implementation difficulties...



1) I will give a brief explanation on this. Whether to update cache or not is decided by query and not by time.

The first query gives me a series of numbers like resulset row1-> 56, resultset row2-> 34 and so on. Everytime I take the count of rows that has value greater then cache's max value..eg 56 here. If count is more then zero, that means report needs to be updated.

So, I was thinking that with every request, this query should be executed. So essentially I want to execute this query before "getReport" for every request.something like



But then, it will again increase amont of time threads have to wait. The database operations are such that there are fewer inserts/updates but more reads.
So, in this case is this approach more feasible or running "updateReport" in background? Also, how do I run "updateReport" in background in spring? I guess I would have to implement "updateReport" in class that extends Runnable or something like that.

2) You also mentioned in TestControllerServlet:-


I guess, here "tcoReport" and "tco" are class level variables and not local variables inside "onSubmit" method. Essentially, I will be using
same instance of "TestControllerOutput" ie tco for every requests. Am I right?

Sorry for a very long post.
14 years ago
Now, what I intend to do is as soon as user requests for this page, queries are executed, beans are loaded and placed in arraylist and arraylist is
cached at application and not session scope.Next time user requests the page, certain queries are performed to determine validity of existing cache. If
cache is valid, just use the same cache instead of generating a new report.


I have following configuration in dispatcher-servlet.xml:-



where TestController1 extends SimpleFormController..



I intend to use below approach in my TestController class:-




I have a TestControllerOutput Class



and then there is CacheBean class which actually contains data....

Now my approach is to have 1 instance of CacheBean used by 1 instance of TestControllerOutput and
I believe from above approach, TestController1 will give same instance of TestControllerOutput to every threads.

Is this approach valid?

14 years ago
thank you guys for your help..So, I should be using "application scope" to save arraylist.
I now have an additional question on this approach. What will happen if 2 different requests come at same time.

1 request for getting cached data and other for updating cache with new data. Should I take care of synchronizatiom issue here because eventually
same "application scope" cache will be used for every requests...
14 years ago
JSP
Here is what I intend to do:-

I am using spring mvc framework in my web app. I have ouput page called "TestOP.jsp",
which will essentially itearate through ArrayList of beans and dipslay results in necessary format.

Now, many queries are executed to prepare this report and hence it takes long time in generating the report.
What I want is to give user option to:-
1) view previously generated report OR
2) generate the report once again

If user goes for option-2, then "TestOP.jsp" page should display latest report as well as save that report in static HTML file, say "LastObtainedResult_MMDDYYHHmmSS.html", so that when next time, a user selects option-1 from above, "LastObtainedResult_MMDDYYHHmmSS.html" is directly fetched.

Is this possible through jsp? I believe, jsp session caching is not the solution here, as I want the static html to be available by anybody even after session is closed.

I hope I have made myself clear. Any suggestions will be most helpful..Or is there a better and different solution to this problem?

Thanks..




14 years ago
JSP
I logged in messages like :-

I added these messages in respective separate "close" methods..And found that
for each query that is executed, these messages were written to log file...So, I guess
connections leak is not taking place...

Is there any other way where we can find if any connections/statements/resultsets are still
open?
jeanne/Eduardo .. is the above mentioned way of closing connections appropriate way?
I use below procedure for closing connections:-

I have a separate class ConnectionUtils that deals with connections, which contains different methods like


Then in my other classes I have methods in following manner:-


So, I do not essentially close connections in finally block, but in try block and set references to null in finally block.
Is this not a good approach?
I have below mentioned configuration for connection pooling on tomcat server 6.0.20:-



Issue here is, that as day passes by, same query that takes about 12-14 seconds to execute in morning takes about 50-70 seconds later in the day...after say 2-3 hours..
And performance degrades further on..I am sure, something is wrong in my connection pooling configuration in server.xml file.

I am not using hibernate or other ORM frameworks.

Pl let me know how do I optimize this configuration.
I should then:-

1) use same value for commandName for both controllers - tco
2) use different names for formviews "TestInput1 and TestInput2" for both controllers

and spring mvc will create 2 different instances of command class and pass it on to their controllers.

Thanks vishal..

continuing on this, I had a query. If it so happens that many people are requesting for "TestController1" at
same time, does spring mvc create different instances of same command class for each request?
14 years ago
Thanks for the reply KengKaj..
So, if both controllers i.e TestController1 and TestController2 use same command name (tco in this case),
will single instance be shared by 2 controllers or spring mvc creates 2 instances of same class and gives 1
each to 2 controllers
14 years ago