Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

EJB3.0 and Stored Procedure

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the advantage of using Stored Procedure over EJB3.0?.We are calling Stored procedure using Native Query method.In EJB3.0 Framework already having persistent mechanism over tables like em.persist(obj),em.merge(obj),etc.I am concerned that by using native query method bypassing the persistence support provided by the EJB3 framework.So What is the different between native queries and Persistent mechanism?Can any one please elobrate.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sometimes there are no choices but to use Stored procedures to leverage the benifits provided by the database vendors. In certain cases it is worth keeping the business logic in the stored procedures, on top of that they are faster(precompiled), secure and maintainable.

However, I think it may not be good idea making calls to stored procedures or writing native queries from ORM based entities. We had JDBC based DAOs with native SQLs and stored procedures calls, but not in the JPA based Entities. Not having native queries in JPA(any ORM) entities will guarantee your protability between databases.

Can someone elaborate more on this, with some practical pros & cons?
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess it's time for the often used answer "it depends".

I had a customer with various applications based on different technologies (Powerbuilder, Java, Crystal Enterprise, ...) where some of the business logic was kept in stored procedures.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Native Queries will take advantage of any vendor specific implementations.

As such, it is preferred for very large queries but not for transactional functions because JPA provider is not aware of state changes and may result to inconsistent state.

Regards.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic