
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
nDifference between Save and SaveAndFlush in Spring Javan
Save and saveAndFlush both can be used for saving entities. They both are both belong to the Spring data library. save may or may not write your changes to the DB straight away. When we call saveAndFlush system are enforcing the synchronization of your model state with the DB.
Sr. No. | Key | Save | SaveAndFlush |
---|---|---|---|
1 | Repository | It belongs to CrudRepository | It belongs to JPARepository |
2 | Data flush Strategy | It doesn't flush data directly to a database until and unless we explicitly call flush and commit method. | It's flush directly flush data to a database. |
3 | Bulk Save | CrudRepository provides bulk save method | saveAndFlush method doesn't support the bulk operation |
4 | Data Visibility after saving | It doesn't flush data directly to a database, therefore, changes will not be visible outside the transaction unless we explicitly call commit() in this transaction. | Changes will be visible outside the transaction also. |
5 | Use Case | We use this method when we don't need to use the saved changes at a later point in the same transaction. | We use this method when we need to use the saved changes at a later point in the same transaction. |
- Related Articles
- Difference between applicationContext.xml and spring-servlet.xml in Spring Framework
- Difference between DispatcherServlet and ContextLoaderListener in Spring
- Difference between IOC and Dependency Injection in Spring.
- Difference between @Bean and @Component annotation in Spring.
- Difference between Spring AOP and AspectJ AOP
- Difference Between Constructor Injection and Setter Injection in Spring
- Difference between Application context and Beanfactory in Spring framework
- Difference between save() and persist() in Hibernate
- Difference between JDK dynamic proxy and CGLib proxy in Spring
- Difference between Java and JavaScript.
- Difference between Go and Java.
- Difference Between C++ and Java
- Difference between Groovy and Java
- Difference between ArrayList.clear() and ArrayList.removeAll() in java?
- Difference between Applets and Servlets in Java.

Advertisements