(REVERT) BAEL-2095 CrudRepository save() method
This commit is contained in:
parent
9664247f4f
commit
2e60aa32a2
@ -1,29 +0,0 @@
|
|||||||
package com.baeldung.config;
|
|
||||||
|
|
||||||
import com.baeldung.dao.repositories.InventoryRepository;
|
|
||||||
import com.baeldung.domain.MerchandiseEntity;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
@EnableJpaRepositories(basePackageClasses = InventoryRepository.class)
|
|
||||||
@EntityScan(basePackageClasses = MerchandiseEntity.class)
|
|
||||||
public class CustomConfiguration {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ConfigurableApplicationContext context = SpringApplication.run(CustomConfiguration.class, args);
|
|
||||||
|
|
||||||
InventoryRepository repo = context.getBean(InventoryRepository.class);
|
|
||||||
|
|
||||||
MerchandiseEntity pants = new MerchandiseEntity("Pair of Pants");
|
|
||||||
repo.save(pants);
|
|
||||||
|
|
||||||
MerchandiseEntity shorts = new MerchandiseEntity("Pair of Shorts");
|
|
||||||
repo.save(shorts);
|
|
||||||
|
|
||||||
pants.setTitle("Branded Luxury Pants");
|
|
||||||
repo.save(pants);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.baeldung.dao.repositories;
|
|
||||||
|
|
||||||
import com.baeldung.domain.MerchandiseEntity;
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
|
|
||||||
public interface InventoryRepository extends CrudRepository<MerchandiseEntity, Long> {
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.baeldung.domain;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class MerchandiseEntity {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
public MerchandiseEntity() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MerchandiseEntity(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user