Ronald Castillo

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

Recent posts by Ronald Castillo

Hi James,

After taking a look at your solution, I stumbled upon Hibernate's @Any annotation (available since 3.3.1 GA).
Since I'm already using Hibernate in my project I decided to go for this alternative instead of EclipseLink's @VariableOneToOne annotation.

Thanks a lot for the help. I'm marking the thread as resolved.
Hi ranch,

I know the title isn't exactly very descriptive but there's no way to express my situation with few words.

The thing is I'm trying to map the following, I have a legacy database in which one of the tables has a column named "model" and also another one named "model_id".
This table can either have a "foreign key" (not actually a real constraint on the database) to one table or another depending on the model. Something like:

id | model | model_id | status | code
1 | Task | 1 | pending | 156164
2 | Anything | 9 | pending | 647987

When the model is "Anything", the model_id points to the primary key of the table "anythings" and when is "Task" it points to the "tasks" table primary key.

How can I define this in my mapping using JPA? How do I map that table to an object model?

If my explanation was too shallow or you guys need any more information, please let me know.

Thanks a lot in advance

Paul Clapham wrote:Well, he IS using a StringBuilder to construct the big-ass query, so we don't have the dreaded String concatenation problem to deal with. But everything else you said about inserting into the output database one record at a time in batches... +1 to that.

I would have tried to use an "INSERT INTO... FROM SELECT ..." statement, or something like that, so that my code didn't even have to handle the data at all. But perhaps FoxPro doesn't support that kind of query, or perhaps it would have been an unmaintainable mess if it could even be written at all.



The database that I'm inserting the data to is a MySQL database.

How big is your days loop? Also how many records returned from your localTemplate?


About 1.5k records PER day

Generally speaking making one big ass query (yes big ass query is the technical term) for inserting lot of rows into a database is not reccomended.


I need a ALL or NOTHING insert (at least per day), maybe I could have used a transaction, but I'm not sure how the performance is when doing a transaction + insert in a preparedstatement

c) You will send this big ass query to the database, which will need to parse it and the execute it.


I ran a query to get data from 200 days worth of data, at about ~1.5k records a day, out of all those records just 85k were unique, the query just took 315seconds to execute on the MySQL server (remote).
13 years ago
Hi guys,

This time I having a doubt regarding performance. I have a code which reads records from a ODBC DataSource and then inserts it on a MySQL database.
The thing is, when Java is looping thru the records from the ODBC DS, it takes A LOT of CPU (around 50%) and I'm concerned whether this is normal for this type of operations or not.

This is the code I'm using:


Is it supposed to use that much CPU or is there something I can do to improve performance.

PD: The Datasource is a VisualFoxPro DBF db.

(Edited to reduce the excessive width: Paul C)
13 years ago

Paul Clapham wrote:Good question. So what does the API documentation say about those methods?

For your first choice it says

Schedules the specified task for execution at the specified time. If the time is in the past, the task is scheduled for immediate execution.



So if the time you provide it is 2011 September 10 03:00:00 then it runs then. I don't see anything which says it will run again at some future time, so I wouldn't assume it would. However you could try it and see.

I will leave you to read the docs for the other method you mentioned and see if that method does what you want.



I did read the docs, however, wanted to know if someone had tried it. Didn't want to wait a whole day to find out. But, I'm guessing it wont run again, so I'm gonna go with schedule(TimerTask task, Date firstTime, long period) or scheduleAtFixedRate(TimerTask task, Date firstTime, long period) (I'm aware of the difference between them).

Thanks for the help Paul. I love the ranch, I can always get huge help from great people. ;)
13 years ago

Incidentally if you want something to happen at 3 AM every day, then "every 24 hours" isn't an accurate way to do that if you live in a place which observes daylight saving time.


Not worried about that, when I'm from we don't use daylight saving time.

Yes, if you use a Timer to cause your application to do something every 24 hours, then it's going to be permanently in memory.



So, we could say this would be enough (example):


Or do I need to specify the 24 hours (in milliseconds) on the following line:
timer.schedule(new AlarmTask(), alarmTime, hoursInMilliseconds);
13 years ago
Hello ranch,

I'm going to create a Java app to run as a Windows Service (using the Tanuki Software Wrapper). My app is supposed to run EVERYDAY at a fixed time, let's say: 03:00AM.

My question is, when using the Timer schedule method, if I don't specify the PERIOD, will the task run everyday or I must set a period (in my case equal to a whole day in milliseconds)?

Also, is Timer the best way to run a task at a fixed time? I mean, my application will ALWAYS be running on the background so it can perform the operation at 3:00AM. I'm really concerned about performance and memory usage.
I would've used a scheduled task instead, but they don't want me to (-_-" don't ask)...

Thanks for the help in advance
13 years ago
I think he's referring to Package naming conventions.

You can pretty much name your packages any way you want (with a few exceptions).
But, as for variable names, a convention is encouraged.

http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions
13 years ago
You got your method name wrong, you're using printlp. It's println().
Cannot find symbol usually means that the method you're trying to invoke doesn't exist.
13 years ago
I just tried it and it works flawlessly! Thanks a lot Mark.

Regarding the dependency when using a harcoded path, what I did was get the Path from where my jar is running using the File class, so that as long as the file is in the same directory as my jar, it works just fine. When not found, I added kind of a backup beans.xml inside my jar (with default configuration options).
13 years ago
Thanks for the reply.

Regarding the tutorials I'm following, they're using Spring 3.0:
http://www.vaannila.com/spring/spring-tutorial/spring-tutorial.html

Thanks a lot the help.
13 years ago
Use the setFont method on the JLabel class.
top.add(new JLabel("Welcome to the HI Lo Game!").setFont(new Font("Papyrus", Font.BOLD, 60)));
13 years ago
Try setting your profile page cache headers to an old date so when they try to go back, the page will have expired.
13 years ago
Hi,

I'm REALLY new to Spring and I'm trying out some examples I've seen on the web so I can get familiar with it and learn.
Now, I want to do something but I'm not sure if it's possible or if it is, how to do it.

I created a simple beans.xml file, but since I want to deploy my app in a .jar file, I want to take the beans.xml OUT of my jar file so if anyone needs to change some configuration option, they don't have to touch the app or recompile.


Thanks for the help.

PD: I'm using Eclipse as my IDE.
13 years ago
I'm really looking on getting a book so I can learn how to use Spring.

By going to the website, the Spring Security, Mobile and Android extensions catched (specially the Security extension) my eye and I'm wondering whether this book covers those topics?

If it does, is it recommended for a Android newbie to use Spring Android on his projects?

Thanks for the replies ;)
13 years ago