英文:
Inflate inner class in entity in Spring Boot
问题
我有一个实体和连接的JPA存储库。我需要初始化主对象,这对我有用,但我不能膨胀主实体中的内部对象。例如:
SQL:
select id, latitude, longitude from user where id = 1;
结构:
@Entity
@Table(name="user")
class User {
@Id
Integer id;
Location location = new Location();
public static class Location {
@Column(name="latitude")
double latitude;
@Column(name="longitude")
double longitude;
}
}
英文:
I've entity and connected JPA repository. I need init main object and it's work for me but I can't inflate inner object in main entity. For example:
SQL:
select id, latitude, longitude from user where id = 1;
Struct:
@Entity
@Table(name="user")
class User {
@Id
Integer id;
Location location = new Location();
public static class Location {
@Column(name="latitude")
double latitude;
@Column(name="longitude")
double longitude;
}
}
专注分享java语言的经验与见解,让所有开发者获益!
评论