• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Framework for simpler stored procedure access?

 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Is there any framework that creates java stubs for stored procedures?
So I point the generator tool to my DB, it scans the stored procedures there and creates java code.

So instead of this:


I could write:


Or even: generatedCode.my_proc_2(20,4,"foo",5).getResult() and it would have the correct type for the returned data.

I tried Spring JDBC and cayenne , but the code needed to type manually is more or less the same as with plain JDBC.

Regards,
David
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not exactly the same, but Javaranch has the Jenny code generator for database code.
 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jenny does not seem to do anything for stored procedures.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Have you looked at the iBatis ?
It may not generate the every part of the code but you can configure the stored procs. in a XML.
If you follow some standard writing all the stored procs. for e.g if you define all of your stored procs. would have one input and one output parameter then you can have a single DAO class interacting with all stored procs adhering to this standard. Whenever you have another procedure to be invoked you just need to add its specification in the XML file.

Regards,
amit
 
David Balažic
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amit punekar wrote:Hi,
Have you looked at the iBatis ?

Yes.
As we have predefined stored procedures, it does not offer any more that for example cayenne. (which is almost nothing, as the need for handwritten code is almost the same as with plain JDBC).
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is no, there is not a framework, in part because stored procedures differ greatly among DBMS's. Take your source code, for example, which relies on "OracleTypes" values, something obviously specific for Oracle.

For iBatis, keep in mind the goal is not necessarily to write shorter code but make the code easier to change. For example, with iBatis you can change the name of the stored procedure in XML without recompiling the Java code. Indirection can be a useful, if not immediately obvious, feature.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic