java - All business logic in stored procedure -
my project's using n-tier architecture , common framework as:
- presentation layer: jsf 2.0 + primefaces
- business logic layer: spring management transaction
- data access layer: spring data + jpa
- spring security security , user management
- spring integration integration external system
for business logic, we're using java code , reside in business layer, client requires move business logic database , use stored procedures (database oracle).
i tried convince client , give disadvantage , advantage if move business logic database below:
disadvantages:
- stored procedure not programming language, should use manage data , not write logic code
- stored procedure make logic become complex. 1 logic maybe difficult implement stored procedure easy if use programming language java
- difficult debug or unit test
- diffucult handler exception
- difficult maintenance, update
- stored procedure can't integrate external system
- take effort write crud each table when orm framework's crud
- difficult make clear design document
- more bugs
- slow down development process
- database server become overloaded
- database should use handling data not process logic
- difficult , expensive upgrade or add new database server, easier , cheaper application server
- break n-tier architecture , orm framework
when using stored procedures:
- performance: process batch data or long time process database (as report...)
my client said: want use store fix project without redeploy. , explain when change business logic maybe need change input, output , user interface, still have redeploy, , should bring business logic out of database. rejected.
if using oracle db never try underestimate power of stored procedure.i worked in many heavy application , yes had java layer processing huge data business logic not possible @ in java layer. moved of data processing logic in stored procedure , rocks anything.
for example want show logical report @ front end , sure few kbs , know generate report calling db , fetching records in mb , doing business logic in java, fast??
i java guy still supports stored procedure can lot can write useful business logic in it.
as stored procedure works in db layer fast compare java.as per opinion complex db related queries have in java business layer move stored procedure , retrieve required output using java , display same @ frontend.
in addition want put best pros of stored procedure.
its faster because multiple sql queries , such can performed in 1 "round trip" database
trivial make use of stored procedures multiple applications
one place easier maintain multiple
databases fast , optimized , can scaled well.
the same procedures can called mutiple, different frameworks , languages.
the logic decoupled implementation in particular applications.
rework may reduced changing applications when database stays same.
Comments
Post a Comment