diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java index 89c29bd..892c09a 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java @@ -18,6 +18,7 @@ import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; /** * This class implements Author entity which forms @@ -69,6 +70,9 @@ public class Author { regexp = regexCommon, message = "Invalid characters" ) + @JsonProperty( + value = "firstname" + ) private String firstName; ////////// @@ -88,6 +92,9 @@ public class Author { regexp = regexCommon, message = "Invalid characters" ) + @JsonProperty( + value = "lastname" + ) private String lastName; // Omit from Jackson JSON serialization diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java index 010433f..e293934 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java @@ -103,7 +103,7 @@ public class Book { targetEntity = BookHash.class ) @PrimaryKeyJoinColumn - private BookHash bookHash; + private BookHash bookhash; //////////////////// // Attributes with hard-coded constraints @@ -234,9 +234,13 @@ public class Book { public void setId(Long id) { this.id = id; } - - public void setBookHash(BookHash bookHash) { - this.bookHash = bookHash; +/* + @JsonProperty( + value = "bookhash" + ) +*/ + public void setBookHash(BookHash bookhash) { + this.bookhash = bookhash; } public void setTitle(String title) { @@ -272,8 +276,9 @@ public class Book { return id; } + @JsonIgnore public BookHash getBookHash() { - return bookHash; + return bookhash; } public String getTitle() { @@ -321,7 +326,7 @@ public class Book { @Override public String toString() { return "[" + "id: " + this.id + ", " + - "bookhash_id: " + this.bookHash + ", " + + "bookhash_id: " + this.bookhash + ", " + "title: " + this.title + ", " + "author: " + this.author + ", " + "year: " + this.year + ", " + diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java index 6e6bec1..ae8a29e 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java @@ -18,6 +18,7 @@ import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; /** * This class implements BookHash entity which forms @@ -68,7 +69,7 @@ public class BookHash { @OneToOne( cascade = { CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY, - mappedBy = "bookHash", + mappedBy = "bookhash", targetEntity = Book.class ) @PrimaryKeyJoinColumn( @@ -86,6 +87,9 @@ public class BookHash { updatable = false, nullable = false ) + @JsonProperty( + value = "hashid" + ) private String hashId; diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java index 301df54..eb26466 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java @@ -30,9 +30,9 @@ public interface BookHashRepository extends CrudRepository { */ @Modifying @Query( - value = "DELETE FROM BOOK_HASH i WHERE i.book_id = :bookId", + value = "DELETE FROM BOOK_HASH i WHERE i.book_id = :bookid", nativeQuery = true ) - public void deleteByBookId(@Param("bookId") Long bookId); + public void deleteByBookId(@Param("bookid") Long bookId); } \ No newline at end of file