From d3d5bedb018cf83b80b89db367111aa306e10db5 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 3 Jul 2016 17:46:47 +0200 Subject: [PATCH] Spring JPA: renaming packages --- .../OffsetDateTimeAttributeConverter.java | 39 ++++++ .../de/spring/example/persistence/domain/Ad.java | 131 ++++++++++++++++++++ .../example/persistence/domain/AdDescription.java | 102 ++++++++++++++++ .../repository/AdDescriptionRepository.java | 14 +++ .../persistence/repository/AdRepository.java | 20 ++++ .../example/rest/controllers/AdController.java | 23 ++++ .../OffsetDateTimeAttributeConverter.java | 39 ------ .../de/spring/persistence/example/domain/Ad.java | 132 --------------------- .../persistence/example/domain/AdDescription.java | 100 ---------------- .../repository/AdDescriptionRepository.java | 14 --- .../example/repository/AdRepository.java | 20 ---- .../de/spring/rest/controllers/AdController.java | 23 ---- .../spring-configuration/jpa-configuration.xml | 6 +- .../spring-configuration/mvc/rest/rest-config.xml | 2 +- 14 files changed, 333 insertions(+), 332 deletions(-) create mode 100644 SpringJava/JPA/src/main/java/de/spring/example/persistence/converters/OffsetDateTimeAttributeConverter.java create mode 100644 SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/Ad.java create mode 100644 SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/AdDescription.java create mode 100644 SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java create mode 100644 SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java create mode 100644 SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java delete mode 100644 SpringJava/JPA/src/main/java/de/spring/persistence/converters/OffsetDateTimeAttributeConverter.java delete mode 100644 SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/Ad.java delete mode 100644 SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/AdDescription.java delete mode 100644 SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdDescriptionRepository.java delete mode 100644 SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdRepository.java delete mode 100644 SpringJava/JPA/src/main/java/de/spring/rest/controllers/AdController.java diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/converters/OffsetDateTimeAttributeConverter.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/converters/OffsetDateTimeAttributeConverter.java new file mode 100644 index 0000000..30ab6bb --- /dev/null +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/converters/OffsetDateTimeAttributeConverter.java @@ -0,0 +1,39 @@ +package de.spring.example.persistence.converters; + +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; + +@Converter(autoApply = true) +public class OffsetDateTimeAttributeConverter implements AttributeConverter { + + @Override + public Timestamp convertToDatabaseColumn(OffsetDateTime offsetDateTime) { + Timestamp timestamp = null; + + if (offsetDateTime != null) { + timestamp = Timestamp.valueOf(offsetDateTime.toLocalDateTime()); + } + + return timestamp; + } + + @Override + public OffsetDateTime convertToEntityAttribute(Timestamp sqlTimestamp) { + OffsetDateTime offsetDateTime = null; + + if (sqlTimestamp != null) { + final LocalDateTime localDateTime = sqlTimestamp.toLocalDateTime(); + final ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault()); + offsetDateTime = zonedDateTime.toOffsetDateTime(); + } + + return offsetDateTime; + } + +} diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/Ad.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/Ad.java new file mode 100644 index 0000000..5ef5871 --- /dev/null +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/Ad.java @@ -0,0 +1,131 @@ +package de.spring.example.persistence.domain; + +import java.io.Serializable; +import java.time.OffsetDateTime; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Convert; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +//import javax.persistence.NamedNativeQueries; +//import javax.persistence.NamedNativeQuery; +//import javax.persistence.NamedQueries; +//import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.Max; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import de.spring.example.persistence.converters.OffsetDateTimeAttributeConverter; + +@Entity +@Table(name="ad", schema="mybatis_example") +// 1. Named query is JPL. It is portable. +// 2. Instead of annotating the domain class we should be using @Query annotation at the query method +// because it should be cleaner :) +// So you'd better use @Query. +//http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.at-query +//See: de.spring.persistence.example.repository.AdRepository +//@NamedQueries( +// { +// @NamedQuery( +// name="Ad.findByIdQuery", +// query="select a from Ad a where a.id = :id) +// } +// +//) +// 1. Native query IS NOT JPL. It is not portable and it is written directly in the native language +// of the store. We can use special features at the cost of portability. +// 2. Instead of annotating the domain class we should be using @Query annotation at the query method +// because it should be cleaner :) +// So you'd better use @Query. +// http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.at-query +// See: de.spring.persistence.example.repository.AdRepository +//@NamedNativeQueries( +// { +// @NamedNativeQuery( +// name="Ad.findByIdNativeQuery", +// query="SELECT * FROM ad WHERE ad.id = :id", +// resultClass=Ad.class) +// } +//) +public class Ad implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id", updatable=false, nullable=false) + private Long id; + + @OneToMany(mappedBy="ad", fetch=FetchType.LAZY, targetEntity=AdDescription.class) + private Set adDescriptions; + + @Max(60) + @Column(name="company_id") + private Long companyId; + + @Max(40) + @Column(name="company_categ_id") + private Long companyCategId; + + @Size(min=2, max=255) + @Column(name="ad_mobile_image") + private String adMobileImage; + + @NotNull + @Convert(converter=OffsetDateTimeAttributeConverter.class) + @Column(name="created_at", nullable=false) + @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ssZ") + private OffsetDateTime createdAt; + + @NotNull + @Convert(converter=OffsetDateTimeAttributeConverter.class) + @Column(name="updated_at", nullable = false) + @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ssZ") + private OffsetDateTime updatedAt; + + // It will be used by JPA when filling the property fields with data coming from data base. + protected Ad() { + + } + + // It will be used by my code (for example by Unit Tests) + public Ad(Long id, Long companyId, Long companyCategId, String adMobileImage, OffsetDateTime createdAt, + OffsetDateTime updatedAt) { + this.id = id; + this.companyCategId = companyCategId; + this.adMobileImage = adMobileImage; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public Long getId() { + return id; + } + + public Long getCompanyId() { + return companyId; + } + + public Long getCompanyCategId() { + return companyCategId; + } + + public String getAdMobileImage() { + return adMobileImage; + } + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } +} diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/AdDescription.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/AdDescription.java new file mode 100644 index 0000000..9a65407 --- /dev/null +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/domain/AdDescription.java @@ -0,0 +1,102 @@ +package de.spring.example.persistence.domain; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.constraints.Max; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import de.spring.example.persistence.domain.Ad; + +@Entity +@Table(name="ad_description", schema="mybatis_example") +public class AdDescription implements Serializable { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id", updatable=false, nullable=false) + private Long id; + + @NotNull + @ManyToOne(optional=false) + @JoinColumn(name="ad_id", referencedColumnName="id") + private Ad ad; + + @NotNull + @Max(60) + @Column(name="language_id") + private Long languageId; + + @NotNull + @Size(min=2, max=255) + @Column(name="ad_name") + private String adName; + + @NotNull + @Size(min=2, max=255) + @Column(name="ad_description") + private String adDescription; + + @NotNull + @Size(min=2, max=500) + @Column(name="ad_mobile_text") + private String adMobileText; + + @NotNull + @Size(min=2, max=3000) + @Column(name="ad_link") + private String adLink; + + // It will be used by JPA when filling the property fields with data coming from data base. + protected AdDescription() { + + } + + // It will be used by my code (for example by Unit Tests) + public AdDescription(Long id, Ad ad, Long languageId, String adName, String adDescription, + String adMobileText, String adLink) { + this.id = id; + this.languageId = languageId; + this.ad = ad; + this.adName = adName; + this.adDescription = adDescription; + this.adMobileText = adMobileText; + this.adLink = adLink; + } + + public Long getId() { + return id; + } + + public Ad getAd() { + return ad; + } + + public Long getLanguageId() { + return languageId; + } + + public String getAdName() { + return adName; + } + + public String getAdDescription() { + return adDescription; + } + + public String getAdMobileText() { + return adMobileText; + } + + public String getAdLink() { + return adLink; + } +} diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java new file mode 100644 index 0000000..8116883 --- /dev/null +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java @@ -0,0 +1,14 @@ +package de.spring.example.persistence.repository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.PagingAndSortingRepository; + +import de.spring.example.persistence.domain.Ad; +import de.spring.example.persistence.domain.AdDescription; + +public interface AdDescriptionRepository extends PagingAndSortingRepository { + + // Custom Query method + Page findByAd(Ad ad, Pageable pageable); +} diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java new file mode 100644 index 0000000..a9b204f --- /dev/null +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java @@ -0,0 +1,20 @@ +package de.spring.example.persistence.repository; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; + +import de.spring.example.persistence.domain.Ad; + +public interface AdRepository extends PagingAndSortingRepository { + + // Named Native Query (using the native language of the store) It is not portable. + // See de.spring.persistence.example.domain.Ad + @Query(value="SELECT * FROM ad WHERE ad.id = :id", nativeQuery=true) + Ad findByIdNativeQuery(@Param("id") Long id); + + // Named Query (using JPL) It is portable. + // See de.spring.persistence.example.domain.Ad + @Query("select a from Ad a where a.id = :id") + Ad findByIdQuery(@Param("id") Long id); +} diff --git a/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java b/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java new file mode 100644 index 0000000..976a1df --- /dev/null +++ b/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java @@ -0,0 +1,23 @@ +package de.spring.example.rest.controllers; + +import javax.inject.Inject; + +import org.resthub.web.controller.RepositoryBasedRestController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import de.spring.example.persistence.domain.Ad; +import de.spring.example.persistence.repository.AdRepository; + +@RestController +@RequestMapping("/ads/") +public class AdController extends RepositoryBasedRestController { + + @Override + @Inject + public void setRepository(AdRepository repository) { + this.repository = repository; + } + + // I do not have to do anything here because all I need is implemented by RepositoryBasedRestController :) +} diff --git a/SpringJava/JPA/src/main/java/de/spring/persistence/converters/OffsetDateTimeAttributeConverter.java b/SpringJava/JPA/src/main/java/de/spring/persistence/converters/OffsetDateTimeAttributeConverter.java deleted file mode 100644 index 3573265..0000000 --- a/SpringJava/JPA/src/main/java/de/spring/persistence/converters/OffsetDateTimeAttributeConverter.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.spring.persistence.converters; - -import java.sql.Timestamp; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; - -@Converter(autoApply = true) -public class OffsetDateTimeAttributeConverter implements AttributeConverter { - - @Override - public Timestamp convertToDatabaseColumn(OffsetDateTime offsetDateTime) { - Timestamp timestamp = null; - - if (offsetDateTime != null) { - timestamp = Timestamp.valueOf(offsetDateTime.toLocalDateTime()); - } - - return timestamp; - } - - @Override - public OffsetDateTime convertToEntityAttribute(Timestamp sqlTimestamp) { - OffsetDateTime offsetDateTime = null; - - if (sqlTimestamp != null) { - final LocalDateTime localDateTime = sqlTimestamp.toLocalDateTime(); - final ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault()); - offsetDateTime = zonedDateTime.toOffsetDateTime(); - } - - return offsetDateTime; - } - -} diff --git a/SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/Ad.java b/SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/Ad.java deleted file mode 100644 index eb41328..0000000 --- a/SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/Ad.java +++ /dev/null @@ -1,132 +0,0 @@ -package de.spring.persistence.example.domain; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.util.Set; - -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -//import javax.persistence.NamedNativeQueries; -//import javax.persistence.NamedNativeQuery; -//import javax.persistence.NamedQueries; -//import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.validation.constraints.Max; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import de.spring.persistence.converters.OffsetDateTimeAttributeConverter; - -@Entity -@Table(name="ad", schema="mybatis_example") -// 1. Named query is JPL. It is portable. -// 2. Instead of annotating the domain class we should be using @Query annotation at the query method -// because it should be cleaner :) -// So you'd better use @Query. -//http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.at-query -//See: de.spring.persistence.example.repository.AdRepository -//@NamedQueries( -// { -// @NamedQuery( -// name="Ad.findByIdQuery", -// query="select a from Ad a where a.id = :id) -// } -// -//) -// 1. Native query IS NOT JPL. It is not portable and it is written directly in the native language -// of the store. We can use special features at the cost of portability. -// 2. Instead of annotating the domain class we should be using @Query annotation at the query method -// because it should be cleaner :) -// So you'd better use @Query. -// http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.at-query -// See: de.spring.persistence.example.repository.AdRepository -//@NamedNativeQueries( -// { -// @NamedNativeQuery( -// name="Ad.findByIdNativeQuery", -// query="SELECT * FROM ad WHERE ad.id = :id", -// resultClass=Ad.class) -// } -//) -public class Ad implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name="id", updatable=false, nullable=false) - private Long id; - - @OneToMany(mappedBy="ad", fetch=FetchType.LAZY, targetEntity=AdDescription.class) - private Set adDescriptions; - - @Max(60) - @Column(name="company_id") - private Long companyId; - - @Max(40) - @Column(name="company_categ_id") - private Long companyCategId; - - @Size(min=2, max=255) - @Column(name="ad_mobile_image") - private String adMobileImage; - - @NotNull - @Convert(converter=OffsetDateTimeAttributeConverter.class) - @Column(name="created_at", nullable=false) - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ssZ") - private OffsetDateTime createdAt; - - @NotNull - @Convert(converter=OffsetDateTimeAttributeConverter.class) - @Column(name="updated_at", nullable = false) - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ssZ") - private OffsetDateTime updatedAt; - - // It will be used by JPA when filling the property fields with data coming from data base. - protected Ad() { - - } - - // It will be used by my code (for example by Unit Tests) - public Ad(Long id, Long companyId, Long companyCategId, String adMobileImage, OffsetDateTime createdAt, - OffsetDateTime updatedAt) { - this.id = id; - this.companyCategId = companyCategId; - this.adMobileImage = adMobileImage; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } - - public Long getId() { - return id; - } - - public Long getCompanyId() { - return companyId; - } - - public Long getCompanyCategId() { - return companyCategId; - } - - public String getAdMobileImage() { - return adMobileImage; - } - - public OffsetDateTime getCreatedAt() { - return createdAt; - } - - public OffsetDateTime getUpdatedAt() { - return updatedAt; - } -} diff --git a/SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/AdDescription.java b/SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/AdDescription.java deleted file mode 100644 index a3b7d16..0000000 --- a/SpringJava/JPA/src/main/java/de/spring/persistence/example/domain/AdDescription.java +++ /dev/null @@ -1,100 +0,0 @@ -package de.spring.persistence.example.domain; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.Max; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -@Entity -@Table(name="ad_description", schema="mybatis_example") -public class AdDescription implements Serializable { - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name="id", updatable=false, nullable=false) - private Long id; - - @NotNull - @ManyToOne(optional=false) - @JoinColumn(name="ad_id", referencedColumnName="id") - private Ad ad; - - @NotNull - @Max(60) - @Column(name="language_id") - private Long languageId; - - @NotNull - @Size(min=2, max=255) - @Column(name="ad_name") - private String adName; - - @NotNull - @Size(min=2, max=255) - @Column(name="ad_description") - private String adDescription; - - @NotNull - @Size(min=2, max=500) - @Column(name="ad_mobile_text") - private String adMobileText; - - @NotNull - @Size(min=2, max=3000) - @Column(name="ad_link") - private String adLink; - - // It will be used by JPA when filling the property fields with data coming from data base. - protected AdDescription() { - - } - - // It will be used by my code (for example by Unit Tests) - public AdDescription(Long id, Ad ad, Long languageId, String adName, String adDescription, - String adMobileText, String adLink) { - this.id = id; - this.languageId = languageId; - this.ad = ad; - this.adName = adName; - this.adDescription = adDescription; - this.adMobileText = adMobileText; - this.adLink = adLink; - } - - public Long getId() { - return id; - } - - public Ad getAd() { - return ad; - } - - public Long getLanguageId() { - return languageId; - } - - public String getAdName() { - return adName; - } - - public String getAdDescription() { - return adDescription; - } - - public String getAdMobileText() { - return adMobileText; - } - - public String getAdLink() { - return adLink; - } -} diff --git a/SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdDescriptionRepository.java b/SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdDescriptionRepository.java deleted file mode 100644 index d59ade2..0000000 --- a/SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdDescriptionRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.spring.persistence.example.repository; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.repository.PagingAndSortingRepository; - -import de.spring.persistence.example.domain.Ad; -import de.spring.persistence.example.domain.AdDescription; - -public interface AdDescriptionRepository extends PagingAndSortingRepository { - - // Custom Query method - Page findByAd(Ad ad, Pageable pageable); -} diff --git a/SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdRepository.java b/SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdRepository.java deleted file mode 100644 index 24b9c47..0000000 --- a/SpringJava/JPA/src/main/java/de/spring/persistence/example/repository/AdRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.spring.persistence.example.repository; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; - -import de.spring.persistence.example.domain.Ad; - -public interface AdRepository extends PagingAndSortingRepository { - - // Named Native Query (using the native language of the store) It is not portable. - // See de.spring.persistence.example.domain.Ad - @Query(value="SELECT * FROM ad WHERE ad.id = :id", nativeQuery=true) - Ad findByIdNativeQuery(@Param("id") Long id); - - // Named Query (using JPL) It is portable. - // See de.spring.persistence.example.domain.Ad - @Query("select a from Ad a where a.id = :id") - Ad findByIdQuery(@Param("id") Long id); -} diff --git a/SpringJava/JPA/src/main/java/de/spring/rest/controllers/AdController.java b/SpringJava/JPA/src/main/java/de/spring/rest/controllers/AdController.java deleted file mode 100644 index ae0e29f..0000000 --- a/SpringJava/JPA/src/main/java/de/spring/rest/controllers/AdController.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.spring.rest.controllers; - -import javax.inject.Inject; - -import org.resthub.web.controller.RepositoryBasedRestController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import de.spring.persistence.example.domain.Ad; -import de.spring.persistence.example.repository.AdRepository; - -@RestController -@RequestMapping("/ads/") -public class AdController extends RepositoryBasedRestController { - - @Override - @Inject - public void setRepository(AdRepository repository) { - this.repository = repository; - } - - // I do not have to do anything here because all I need is implemented by RepositoryBasedRestController :) -} diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/jpa-configuration.xml b/SpringJava/JPA/src/main/resources/spring-configuration/jpa-configuration.xml index 1a16615..2a7f621 100644 --- a/SpringJava/JPA/src/main/resources/spring-configuration/jpa-configuration.xml +++ b/SpringJava/JPA/src/main/resources/spring-configuration/jpa-configuration.xml @@ -15,7 +15,7 @@ - + @@ -28,11 +28,11 @@ - + diff --git a/SpringJava/JPA/src/main/resources/spring-configuration/mvc/rest/rest-config.xml b/SpringJava/JPA/src/main/resources/spring-configuration/mvc/rest/rest-config.xml index 1c2f309..d6a3185 100644 --- a/SpringJava/JPA/src/main/resources/spring-configuration/mvc/rest/rest-config.xml +++ b/SpringJava/JPA/src/main/resources/spring-configuration/mvc/rest/rest-config.xml @@ -25,7 +25,7 @@ - +