-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
956 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"fluentMethods": true, | ||
"relationships": [ | ||
{ | ||
"relationshipType": "one-to-many", | ||
"relationshipName": "item", | ||
"otherEntityName": "item", | ||
"otherEntityRelationshipName": "cart" | ||
}, | ||
{ | ||
"relationshipType": "one-to-one", | ||
"relationshipName": "customer", | ||
"otherEntityName": "customer", | ||
"ownerSide": false, | ||
"otherEntityRelationshipName": "cart" | ||
} | ||
], | ||
"fields": [], | ||
"changelogDate": "20171208125341", | ||
"entityTableName": "cart", | ||
"dto": "no", | ||
"pagination": "no", | ||
"service": "no", | ||
"jpaMetamodelFiltering": false | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package org.apeps.firstapp.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import org.hibernate.annotations.Cache; | ||
import org.hibernate.annotations.CacheConcurrencyStrategy; | ||
|
||
import javax.persistence.*; | ||
import java.io.Serializable; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.Objects; | ||
|
||
/** | ||
* A Cart. | ||
*/ | ||
@Entity | ||
@Table(name = "cart") | ||
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | ||
public class Cart implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") | ||
@SequenceGenerator(name = "sequenceGenerator") | ||
private Long id; | ||
|
||
@OneToMany(mappedBy = "cart") | ||
@JsonIgnore | ||
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | ||
private Set<Item> items = new HashSet<>(); | ||
|
||
@OneToOne(mappedBy = "cart") | ||
@JsonIgnore | ||
private Customer customer; | ||
|
||
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Set<Item> getItems() { | ||
return items; | ||
} | ||
|
||
public Cart items(Set<Item> items) { | ||
this.items = items; | ||
return this; | ||
} | ||
|
||
public Cart addItem(Item item) { | ||
this.items.add(item); | ||
item.setCart(this); | ||
return this; | ||
} | ||
|
||
public Cart removeItem(Item item) { | ||
this.items.remove(item); | ||
item.setCart(null); | ||
return this; | ||
} | ||
|
||
public void setItems(Set<Item> items) { | ||
this.items = items; | ||
} | ||
|
||
public Customer getCustomer() { | ||
return customer; | ||
} | ||
|
||
public Cart customer(Customer customer) { | ||
this.customer = customer; | ||
return this; | ||
} | ||
|
||
public void setCustomer(Customer customer) { | ||
this.customer = customer; | ||
} | ||
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Cart cart = (Cart) o; | ||
if (cart.getId() == null || getId() == null) { | ||
return false; | ||
} | ||
return Objects.equals(getId(), cart.getId()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(getId()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Cart{" + | ||
"id=" + getId() + | ||
"}"; | ||
} | ||
} |
This file contains 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
This file contains 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
16 changes: 16 additions & 0 deletions
16
src/main/java/org/apeps/firstapp/repository/CartRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.apeps.firstapp.repository; | ||
|
||
import org.apeps.firstapp.domain.Cart; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import org.springframework.data.jpa.repository.*; | ||
|
||
|
||
/** | ||
* Spring Data JPA repository for the Cart entity. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Repository | ||
public interface CartRepository extends JpaRepository<Cart, Long> { | ||
|
||
} |
Oops, something went wrong.