I have a user entity:
@Entity(name = "users")
@DynamicUpdate
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
@JsonIgnore
@JsonIgnoreProperties("user")
private Set<Car> cars;
}
and a car entity:
@Entity(name = "cars")
@DynamicUpdate
public class Car implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "plate_number")
@JsonView(View.Summary.class)
private String plateNumber;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="user_id")
@JsonIgnore
@JsonManagedReference("user-coordinate")
@Access(value = AccessType.FIELD)
private User user;
}
when I get cars list I get this:
{
"id": 5,
"plateNumber": "aaaaada",
"user": {
"id": 110,
"name": null
}
},
But I want to get this(without user entity!):
{
"id": 5,
"plateNumber": "aaaaada",
},
I have 7 years' experience in PHP (I said it to know I am familiar with how to search and get what I want) but I am a beginner in java spring I searched a lot for the answer all I get is that it's related to Jackson but I don't know how to solve it please help me with details I will appreciate it.
Thank you