"Especially if you change say a stored procedure and add a parameter, and you have to find all the places where that procedure is called from.
"
Gagan (/^_^\) SCJP2 SCWCD IBM486 <br />Die-hard JavaMonk -- little Java a day, keeps you going.<br /><a href="http://www.objectfirst.com/blog" target="_blank" rel="nofollow">My Blog</a>
Originally posted by R. M. Menon:
I find it hard to imagine a tool that can generate SQL statements automatically.
Instead of using the least common denominator for all dbs, I believe in exploiting all the features of database (be it Oracle or SQL Server.)
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Gagan Indus:
That�s an interesting point of view.
It kinda goes against the Java philosophy of being able to 'take your code to some other database the next morning'. It will be interesting to see how many times people actually end up doing that, Does any of you have any experience where the DB was actually changed because of some reason X? (it would be good if you can state reason X, and also state the percentage of how many times it have happened in your career versus how many times it haven't)
In my little experience of few years, it has never happened that we changed the production DB. But i can recall one scenario where we used two DBs without needing to change much, it was when we prototyped a part of the application on MySQL and deployed it on Oracle, mostly expanding on the prototype code.
What do you find hard to imagine about that? How do you judge the SQL statements that modern tools like Hibernate *are* generating? Just curious...
I always thought that one reason for using ORM tools was that you exactly *don't* need to restrict yourself to the least common denominator. You just tell the ORM tool *what* you want to do, and it's the job of the tool to determine how it's best done with the specific database you currently use.
To me, that sounds quite promising, at least for the common case.
That doesn't mean that specific database knowledge isn't valuable, of course. I just forwarded the review of your book to our database expert, and he immediately ordered it...
Instead of using the least common denominator for all dbs
Originally posted by Mark Spritzler:
So you have never seen the SQL that Hibernate generates. Hibernate is aware of the database that you are using and uses a lot of the features of that particular database to make things faster. You can use some of the SQL features that are unique to that database through Hibernate. Also Gavin and Christian who created Hibernate know quite a bit about databases and the vendors. So while you can have restraint and concerns over how it does it, unless you know more about it, you can't completely pass judgement on it.
As far as my comments about changing parameters in SPs and the like, I will also bring up a tool from Oracle, to create Java Classes based on Oracle types used as parameters in Stored Procedures called JPublisher. First we have timed queries and stored procedures using JPublisher and Hibernate. Guess what Hibernate was always faster. Also the number of lines of code with JDBC in Java and Hibernate and JPublisher is 500 to 3. Yes you heard me right, it takes 500 lines of code with JDBC and JPublisher, than with Hibernate. Now that is a huge risk, and it is slower. Talk about high costs. So you can't really trust products directly made by the database vendor. You still have to be cautious there.
What always ends up happening when you use JDBC, is your costs rise because of maintenance costs, it is tougher to change something so it is extensible, and when you try to change you are taking higher risks because it usually never works right away and gets frustrating. So then you go and decide to OO its way out of this mess, and what happens you try to write your own Hibernate from scratch.
R.M. I understand you ideas, and I have heard them many times, but it comes from a Database perspective and not a Java perspective. To be honest, I think the costs of Java development is higher than Database development.
I have worked as an Oracle DBA, I have used many things that you see on asktom. My favorite is Over Partition By where you can get aggregates at different levels all within the same query without having to resort to sub queries. I have developed Oracle Forms applications and have written my big share of PL/SQL, I understand your perspective, but I also understand the Java perspective, and the Java stuff you need to do is a much bigger difference than the Oracle stuff, so it needs to be a good compromise. What might be better for Oracle and saves you an extra hour, then costs the Java side an extra 10-20 hours. Trust me, I see it everyday at work.
I agree that if you get to a really complex type of query you need, it is best to let the database handle it, but you can still do that way with Hibernate that doesn't make Java developer have to resort to some really bad coding styles needed when you just use JDBC.
Mark
[ March 17, 2006: Message edited by: Mark Spritzler ]
What might be better for Oracle and saves you an extra hour, then costs the Java side an extra 10-20 hours. Trust me, I see it everyday at work.
I have not seen hibernate work - yes but one can still make judgements about automated SQL versus that which is crafted by a human being who knows his/her SQL.
As I said, if this is the case, why not generate all programs then?
Originally posted by Mark Spritzler:
I deleted the first one for you.
That isn't an argument. You are going to an extreme. Again a place where you have to find compromise, what works best and keep all things in mind. If you don't, you usually end up getten bit on the back end, not a pretty sight.
Mark
Right now we have a database that is running on DB2, but for complex technical reasons we are not sure if we actually have a licence to run DB2. If it turns out we don't have a licence, we will be moving that database to some other product. There's X for you.Originally posted by Gagan Indus:
Does any of you have any experience where the DB was actually changed because of some reason X? (it would be good if you can state reason X, and also state the percentage of how many times it have happened in your career versus how many times it haven't)
~Bill
~Bill
Originally posted by Bill Johnston:
"Does any of you have any experience where the DB was actually changed because of some reason X?"
All the time! I've seen it and seen it and seen it! While I agree that a software package developer might want to do this, I definitely do not think it's wise for an institution. And even in the former case - if the DB vender gets real uppity and fiesty and starts doing things it's own way against pleadings from it's many - or many of it's - customers, well ... hey, it can cripple the software vender. At the very least it can cause it's support staff to have to hear all kinds of flack from the vender's customers.
No, in today's ever changing market, I can't see tying oneself down to any particular DB that tightly. You've got to have an out.
Mind you, performance tuning is real important, but not so important as risking going out of business for.
~Bill
Originally posted by Bill Johnston:
Carrying data from one DB to another is one thing. And I think it's expected that some programming will need to be re-done too. But that's what Java is supposed to be able to help with, isn't it?
As to the "performance tuning" bit ... you got me on that one, as I was being overly general. To be more clear then, I mean - in addition to proper DB administration - thought as to where to place logic as to performance has to be given. But I really don't think it should be the only or main criterion.
Everything is a bit of a compromise. But how much portability do you want to give up for performance? How much performance is enough? At what point are you becoming DB dependant?
~Bill
Originally posted by R. M. Menon:
I have not seen dbs changing like that but then I was with Oracle for quite some time
It is simply not worth it to pay all the money and use only a fraction of the features of a database.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by R. M. Menon:
As I said, hibernate may be good where you can get away with simple SQL.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
That's only one side of the coin. There are also costs and risks in putting more functionality inside the database, or at least questions that need to be answered before we can decide what to do in a specific situation:
- how well can I test it?
- how easy is it to refactor the code?
- how easy is it to debug the code?
- how long are roundtrip times (code, compile, deploy, run)?
- how much database knowledge is available? How costly is it?
- how important is the database for the project?
And the answer for (at least some of) those questions will likely be different from project to project, so the balance between putting code into Java and putting it into the database will be different, too.
Perhaps such projects are just more common than it looks like from your perspective...
And regarding generating programs in general, there are actually quite successful attempts at doing this for very specific domains. Just think about using JAXB for parsing XML.
Might be that vanilla database persistence just is such a domain where it just works "well enough" in the general case? (Doesn't Hibernate even allow to define specific SQL statements for critical parts of the application?)
Originally posted by R. M. Menon:
Bad example. XML is not a programming language.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by R. M. Menon:
These are fairly generic questions - the answers to them could swing the decision either way. The first 2 are not even relevant to the discussion I think (they are too generic).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
So you are saying that whether I put logic into the database or not doesn't affect how easy it is to test or change it?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Just musings here, but I think Java developers too often have a java centric viewpoint of the world.
Originally posted by Manoj Raghuwanshi:
In which case it is preferably easy to implement all the business logic in database stored procedures instead of in java application?
[ March 20, 2006: Message edited by: Manoj Raghuwanshi ]
Originally posted by Mark Spritzler:
Unfortunately, in this case, it was too much of an Oracle centric viewpoint, and an unwillingness to be open to other possibilities to make a better design. And coming from someone, me, that has 15 years Database experience. I am still for having stored procedures, and you can still use Hibernate to encapsulate your database access too. To me, in many cases this is the best solution. For simple CRUD stuff, let Hibernate do its job. When you have more complicated logic or queries, let PL/SQL do its job. You have to be open to both. I found in this case there wasn't that openess.
Mark
Originally posted by Mark Spritzler:
Actually, we aren't talking about business logic in stored procedures but SQL in stored procedures.
It is important to define business logic. But the common use of it, would mean that you do not want any business logic in your stored procedures, just SQL. Because then you would be tightly coupling your business logic with the Database.
Mark
Originally posted by steve souza:
I think both sides of the argument (sql in java, and sql in the db) have their points. I personally think the pendulum in the java community has swung too far towards everything should be in java code.
I worked on a project recently and had some developers that knew nothing about java code, and by letting them create and test and run stored procs it allowed them to be productive on our team. Also, these stored procs were easily usable in other languages like powerbuilder. I do think these stored procs should be hidden in an abstraction layer as much as possible, so if necessary the abstraction layer could be swapped out to work when porting from say Oracle to SQL Server.
Having said that, for enterprise databases switching the back end is a lot harder than just worrying about java code. We have enterprise databases that have such a huge ammount of code that it would be a massive undertaking from a coding standpoint to redo all the apps (multiple java apps many taking different approaches to persistance (remember entity EJBs?)/powerbuilder/unix scripts/cron jobs/backup scripts/db configuration checks/bcp/c programs/c++ programs and much more). Truthfully, in many cases, I think it is more likely we abandon Java than our backend database! And I think this is a point that Java developers never think about. Will you be a Ruby shop in 5 years?
This doesn't count the efforts involved in retraining existing dba's that are Sybase ASE experts to become Oracle experts.
Just musings here, but I think Java developers too often have a java centric viewpoint of the world.
[ March 19, 2006: Message edited by: steve souza ]
"Truthfully, in many cases, I think it is more likely we abandon Java than our backend database!"
Originally posted by Ilja Preuss:
Well, as an "Agilist", I was actually talking about the automated kind of tests that you run by the press of a button after every little change to the system.
Originally posted by Ilja Preuss:
Anyway, all I wanted to say is that "you payed for the db, so you should use it's feature to the maximum" sounded overly simplistic to me - even harmful if taken literally. If after careful consideration of *all* the influences on a project you decide to put more code into the DB, more power to you.
Originally posted by R. M. Menon:
Sure, You can still write such tests. In fact putting code in Pl/sql (or Transact SQL) would make it easier - you can write separate tests for stored procedures and Java layers.
"over simplistic" - is in the eyes of the beholder.
To me doing things that DB can handle best within DB sounds like common sense. To exploit and fully use the capabilities of a very powerful tool seems the right thing to do.
Especially if it makes your application that much more functional and scalable.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
~Bill
That same argument can be used for hibernate, or any other tool: "We invested so many dollars in hibernate training, and it is such a powerful tool - we should make as much use of it as possible."
Doesn't sound good to me, either.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
it is just that in discussions such as these, it is hard to put together years of experience into words that are good enough to convince the people on the other side of the camp