Last active
July 27, 2020 16:20
-
-
Save seycileli/182e0d04b1438514c741b0b2b33d6a4c to your computer and use it in GitHub Desktop.
How To: Create a Crud Repository [JAVA]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Make life easier with this simple step!! | |
* | |
* Create an interface that extends one of your Entity classes | |
* Then import the following below, after your entity class name | |
*/ | |
import org.springframework.data.repository.CrudRepository; | |
public interface EntityClass extends CrudRepository<EntityClass> { | |
} | |
/* | |
* In main runner, create a method | |
*/ | |
@Bean | |
CommandLineRunner runner(EntityClass entityClass) { | |
//deleting subscriber | |
return args -> { | |
entityClass.save(new Subscriber("firstName", "lastName", "[email protected]")); | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment