forked from leelance/spring-boot-all
-
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
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
spring-boot-jpa-querydsl/src/main/java/com/lance/querydsl/entity/CityEntity.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,99 @@ | ||
package com.lance.querydsl.entity; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name="t_city") | ||
public class CityEntity implements Serializable { | ||
private static final long serialVersionUID = -2451005683000059023L; | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
private String state; | ||
|
||
private String country; | ||
|
||
private String map; | ||
|
||
@OneToMany(mappedBy="city", cascade=CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval=true) | ||
private Set<HotelEntity>hotels = new HashSet<>(); | ||
|
||
public CityEntity() { | ||
} | ||
|
||
public CityEntity(String name, String country) { | ||
super(); | ||
this.name = name; | ||
this.country = country; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public String getState() { | ||
return this.state; | ||
} | ||
|
||
public String getCountry() { | ||
return this.country; | ||
} | ||
|
||
public String getMap() { | ||
return this.map; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public void setState(String state) { | ||
this.state = state; | ||
} | ||
|
||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
|
||
public void setMap(String map) { | ||
this.map = map; | ||
} | ||
|
||
public Set<HotelEntity> getHotels() { | ||
return hotels; | ||
} | ||
|
||
public void setHotels(Set<HotelEntity> hotels) { | ||
this.hotels = hotels; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getName() + "," + getState() + "," + getCountry(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
spring-boot-jpa-querydsl/src/main/java/com/lance/querydsl/entity/HotelEntity.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,72 @@ | ||
package com.lance.querydsl.entity; | ||
|
||
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; | ||
|
||
@Entity | ||
@Table(name="t_hotel") | ||
public class HotelEntity implements Serializable { | ||
private static final long serialVersionUID = -6355579263029117475L; | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name="city_id") | ||
private CityEntity city; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false) | ||
private String address; | ||
|
||
protected HotelEntity() { | ||
} | ||
|
||
public HotelEntity(CityEntity city, String name) { | ||
this.city = city; | ||
this.name = name; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public CityEntity getCity() { | ||
return city; | ||
} | ||
|
||
public void setCity(CityEntity city) { | ||
this.city = city; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
} |