In SAP CAP development, understanding CAP persistence is crucial to building reliable and scalable applications. Persistence defines where and how your application stores data, whether locally for development or in enterprise-grade SAP HANA for production. This guide will help beginners and corporate developers understand persistence strategies, database options, and deployment best practices.
For hands-on practice, you can explore a comprehensive SAP course. Learning SAP HANA alongside CAP ensures your applications are production-ready.
CAP Persistence Options
CAP supports multiple persistence options depending on the development or production scenario:
- SQLite – Lightweight, file-based database for local development.
- SAP HANA – Enterprise-grade database optimized for CAP applications.
- Other relational databases – Optional for advanced setups via adapters.
SQLite for Local Development
SQLite is ideal for quick prototyping and local testing. It requires minimal setup and works out-of-the-box with CAP.
Example: Configuring SQLite in package.json
"cds": {
"requires": {
"db": {
"kind": "sqlite",
"model": "db/schema"
}
}
}
Benefits of SQLite:
- Fast setup for development
- No external dependencies
- Lightweight and easy to manage
Limitations:
- Not suitable for large-scale production
- Limited advanced database features
SAP HANA for Production
SAP HANA provides high performance, scalability, and advanced analytics. CAP integrates seamlessly with HANA for enterprise-grade persistence.
Example: Configuring HANA in package.json
"cds": {
"requires": {
"db": {
"kind": "hana",
"model": ["db/schema"],
"credentials": {
"host": "hana.example.com",
"port": 443,
"user": "username",
"password": "password"
}
}
}
}
Benefits of HANA:
- High performance for large datasets
- Advanced analytical capabilities
- Enterprise-grade security and reliability
Best Practices for Persistence
- Use SQLite for development and testing.
- Use SAP HANA for production and performance-critical applications.
- Keep your CDS models database-agnostic for flexibility.
- Use migrations to update HANA schemas safely.
- Leverage CAP services to interact with databases rather than raw SQL.
Deployment Options
Once your CAP application is ready, consider deployment strategies:
- Local testing – Run CAP with SQLite locally.
- Cloud Foundry – Deploy CAP applications on SAP Business Technology Platform (BTP).
- Containers (Docker/Kubernetes) – Package CAP applications with HANA client for scalable deployments.
- Hybrid setups – Use SQLite for testing, HANA in production.
Example: Deploying to Cloud Foundry
cf push my-cap-app -b nodejs_buildpack
This ensures your CAP application connects to HANA in BTP and serves production workloads.
Real-World Example
Imagine an e-commerce CAP application:
- Develop locally using SQLite for Orders, Products, and Customers.
- Test business logic with handlers and hooks.
- Deploy to SAP HANA in Cloud Foundry for production.
- Ensure data persistence, transaction management, and scalability are optimized.
Conclusion
Mastering CAP persistence with SQLite and SAP HANA, along with understanding deployment options, is essential for building robust CAP applications. Starting with SQLite simplifies development, while HANA ensures enterprise-grade performance and reliability.
Combine this practical knowledge with an expert-led SAP course and deepen your backend expertise with SAP HANA to deploy scalable CAP applications.

WhatsApp us