Skip to content

Instantly share code, notes, and snippets.

@seycileli
Last active July 27, 2020 16:20
Show Gist options
  • Save seycileli/182e0d04b1438514c741b0b2b33d6a4c to your computer and use it in GitHub Desktop.
Save seycileli/182e0d04b1438514c741b0b2b33d6a4c to your computer and use it in GitHub Desktop.
How To: Create a Crud Repository [JAVA]
/**
* 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